Results 1 to 7 of 7

Thread: Shell command

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    St. Petersburg, Fl
    Posts
    2

    Shell command

    I'm tring to get a shell to execute a command line program and pass a string in "quotes" and not having any luck. Here is the line of code in question:

    exec = Shell ("C:\program.exe -options") & strText

    It will execute the program but it doesn't send the string with the "quotes". It needs to executes this:

    c:\program.exe -options "needs to be the value of strText in quotes"

    TIA,
    Chris

  2. #2
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    exec = Shell ("C:\program.exe " & strText)

  3. #3
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    or, with "-options" included,

    exec = Shell ("C:\program.exe -options " & strText)

  4. #4
    Addicted Member Sibby's Avatar
    Join Date
    Feb 2001
    Location
    Milwaukee, WI *The United States of America*
    Posts
    144
    Try this, it'll work for launching any EXE and associated file...

    VB Code:
    1. 'in a module
    2. Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    3.  
    4. 'in your code
    5. Call ShellExecute(hwnd, "Open", <your path>, <your command line params>, App.Path, 1)
    If you can think it....you can code it....

  5. #5
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    I think he needs:

    VB Code:
    1. exec = Shell ("C:\program.exe -options " & """" & strText & """")
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  6. #6
    Fanatic Member JPicasso's Avatar
    Join Date
    Aug 2001
    Location
    Kalamazoo, MI
    Posts
    843
    I'm with mcbrain.


    a quick little debug trick is to "string up" your shell call.
    this way you can check it in it's entirety just before it runs...


    VB Code:
    1. MyCompleteShellString = "C:\myprogram.exe -options""" & strtext & """"
    2.  
    3. Shell MyCompleteShellString
    Merry Christmas

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    St. Petersburg, Fl
    Posts
    2
    Well, I thank you all for the input. I tried JPicasso suggesttion and it works flawlessly.

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