|
-
February 29th, 2000, 01:29 PM
#1
shell command
I have this .cmd script that is set up like this
c:\sndmsgl.cmd "type in text here" c:\user-list.txt
how can i use a
shell command to execute the file(sndmsgl.cmd)...text(with quotes)...file(user-list.txt)
-
February 29th, 2000, 01:34 PM
#2
Re: shell command
retval = shell("sndmsgl.cmd ""type in text here"" c:\user-list.txt")
' the "" in the above line will be interpreted as a single " in a string
' this will not be interpreted as the end of the shell command
' the command being executed: sndmsg1.cmd "type in text here" c:\user-list.txt
Tom Cannaerts
[email protected]
The best way to escape a problem, is to solve it.
-
February 29th, 2000, 01:48 PM
#3
sorry this is the vb code
Private Sub txtMessage_DblClick()
Dim txtmess As String
Dim fleSndmsgl
Dim fleList
txtmess = txtMessage.Text
fleSndmsgl = "c:\sndmsgl.cmd"
fleList = "C:\list.txt"
'Shell = (fleSndmsgl & 'txtmess' & fleList) I THINK I NEED HELP WITH QUOTES
-
February 29th, 2000, 01:52 PM
#4
Re: sorry this is the vb code
private Sub txtMessage_DblClick()
Dim txtmess as string
Dim fleSndmsgl
Dim fleList
txtmess = txtMessage.Text
fleSndmsgl = "c:\sndmsgl.cmd"
fleList = "C:\list.txt"
Shell = (fleSndmsgl & """" & txtmess & """" & fleList)
End Sub
Ok, it looks a bit weird, but lets break appart """":
the first " opens a string, then second and third " say that vb must interpret it as one ", and not the end of the string. The 4th " specifies the end of the string
Tom Cannaerts
[email protected]
The best way to escape a problem, is to solve it.
-
February 29th, 2000, 02:41 PM
#5
Re: sorry this is the vb code
Hey cakkie..thanks for the reply...Kind of vague i know. 
umm See that line needs to be like it was typed into one dos line..what I am running into (even with your code) is that it does open the sndmsgl.cmd then puts in the text , but then it tries to open the file in a seprate window (list.txt) what this app should do is the sndmsgl.cmd is a loop that looks at all the list.txt names with the message in quotes... Its a multiple netsend command...why they are asking me to do it this way..heck knows...
if you have any other suggestions lemme at em if not..muuuahhhhaaa
-
February 29th, 2000, 02:55 PM
#6
Re: sorry this is the vb code
How about getting rid of the .cmd altogether?
'Add reference to the scripting runtime
Dim oFS as Scripting.FileSystemObject
Dim oFile as Scripting.TextStream
set oFS = new Scripting.FileSystemObject
set oFile = oFS.OpenTextFile("C:\user-list.txt")
'This next part assumes each name on a
'seperate line.
Dim sMsg as string
sMsg = "This is a test"
Do Until oFile.AtEndOfStream = true
Dim sUser as string
Dim sCmd as string
sUser = Trim(oFile.ReadLine())
sCmd = "net send " & sUser & " " & sCmd
Shell sCmd, vbHide
'If you have too many people in your
'list, you may need to wait some to
'end. You can only run a limited amount
'of DOS shells.
Loop
oFile.Close
set oFile = nothing
set oFS = nothing
Another great but not quite so easy method would be to use the CreateFile and WriteFile APIs to write directly to the mailslot that net send uses.
-
February 29th, 2000, 04:27 PM
#7
Re: sorry this is the vb code
well looks like they wont let me home until i figure it out..haha Thanks everyone i got the answer... here it is
Shell(fleSndmsgl & Chr(34) & txtMess & Chr(34) & fleList)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|