Click to See Complete Forum and Search --> : shell command


February 29th, 2000, 12:29 PM
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)

Cakkie
February 29th, 2000, 12:34 PM
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
slisse@planetinternet.be

The best way to escape a problem, is to solve it.

February 29th, 2000, 12:48 PM
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

Cakkie
February 29th, 2000, 12:52 PM
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
slisse@planetinternet.be

The best way to escape a problem, is to solve it.

February 29th, 2000, 01:41 PM
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

Kyle Burns
February 29th, 2000, 01:55 PM
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, 03:27 PM
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)