Results 1 to 8 of 8

Thread: Solved -- Call exe file with parameter

  1. #1

    Thread Starter
    Lively Member claire99's Avatar
    Join Date
    Nov 2002
    Location
    OH
    Posts
    66

    Solved -- Call exe file with parameter

    Hi,
    I am new in VB. I saw someone call a vb exe file with two parameters like "exefile response.asp c:\request.txt". I just wonder how this exefile handle those two parameters. I mean what methods should be used to handle parameters in vb.
    Thanks for help in advance!

    Claire
    Last edited by claire99; Mar 4th, 2003 at 11:30 AM.
    "And we know that all things work together for good to them that love God,
    to them who are the called according to his purpose. " --- Romans 8:28

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    The command line can be read with the Command$ function.

    eg

    VB Code:
    1. Private Sub Form_Load()
    2.     MsgBox Command$
    3. End Sub

    To test this in the IDE, you can specify commandline parameters in the Project --> Project Properties --> Make tab --> Command Line arguments
    Frans

  3. #3

    Thread Starter
    Lively Member claire99's Avatar
    Join Date
    Nov 2002
    Location
    OH
    Posts
    66
    Thanks, Frans C.
    I'd like to test it. But could please also tell me how to call an exe file with parameters in VB.
    "And we know that all things work together for good to them that love God,
    to them who are the called according to his purpose. " --- Romans 8:28

  4. #4

    Thread Starter
    Lively Member claire99's Avatar
    Join Date
    Nov 2002
    Location
    OH
    Posts
    66
    Sorry, Frans C
    I didn't notice you've already told me how to test it.
    Thanks.
    "And we know that all things work together for good to them that love God,
    to them who are the called according to his purpose. " --- Romans 8:28

  5. #5
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    To run an executable from a VB program, you use the Shell command.

    Something like:

    Shell "C:\Test\MyProg.exe Param1 Param2"

  6. #6

    Thread Starter
    Lively Member claire99's Avatar
    Join Date
    Nov 2002
    Location
    OH
    Posts
    66
    Thanks, JordanChris and Frans C. Both of your ways work.
    One more thing, I know if I want to get the parameters I can use

    Code:
    Dim cmds as String
    cmds = Command
    then I can get both param1 and param2. But how can I get param1 and param2 seperatly? Do I have to using a loop to seperate them?

    Thanks.
    "And we know that all things work together for good to them that love God,
    to them who are the called according to his purpose. " --- Romans 8:28

  7. #7
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Because you write the program, you can decide how the parameters should look like. Look up the Split function, and the InStr function in the help file. I think you need them.
    Frans

  8. #8

    Thread Starter
    Lively Member claire99's Avatar
    Join Date
    Nov 2002
    Location
    OH
    Posts
    66
    I got it! Thanks a lot!
    "And we know that all things work together for good to them that love God,
    to them who are the called according to his purpose. " --- Romans 8:28

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