CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: shell command

  1. #1
    Guest

    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)



  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    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.
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Guest

    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



  4. #4
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    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.
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  5. #5
    Guest

    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


  6. #6
    Join Date
    Feb 2000
    Location
    Indiana
    Posts
    308

    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.


  7. #7
    Guest

    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
  •  





Click Here to Expand Forum to Full Width

Featured