Results 1 to 8 of 8

Thread: Command$ Function

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Hey I was wondering if any of you know how to use the command function to call an exe and then place arguments like in DOS behind it?

  2. #2
    Guest
    Command$ is simply used to retrieve the command line argument.

    For example, if in the prompt, you type: MyApp.exe prompt, Command$ will return "prompt".

    In your case, if you want to open an EXE, use:
    Code:
    Shell Command$, 1

  3. #3
    Addicted Member Michael Woolsey's Avatar
    Join Date
    Nov 2000
    Location
    Calgary, Alberta, Canada.
    Posts
    243
    Are you wanting to execute a different program from within your own, or are you wanting to gather command line parameters to use within your application?

    If you want to call another program you can use the Shell function.

    Code:
    Dim RetVal
    RetVal = Shell("C:\WINDOWS\CALC.EXE", vbNormalFocus) ' Run Calculator.
    If you want to get command line parameters for your application use the Command function.

    Code:
    Dim CmdLine
    CmdLine = Command()
    I hope this is what you were looking for.
    Michael Woolsey
    Application/Web Developer

    Visual Basic 6.0 SP5
    Active Server Pages
    Oracle 9i
    - I'm going to live forever, or die trying!

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    And what would yuou do to pass the arguments? When I try to pass them it just opens the app opens the exe and then does not pass the arguments.

    Example:

    dim str as string
    str = "-argument argument"
    shell(app.exe str), vbmax

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Thanks for the help, what I want to do is call another program, it is a dos app. I then want to pass the arguments into it. Such as

    shell(app.exe -argument argument)

    When I call the Dos app it just does the exe and then does not place the arguments in their.

    Any suggestions?

    I don't need to use the shell this is all I know.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Anymore suggestions?

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Anymore ideas?????????

  8. #8
    Member
    Join Date
    Oct 2000
    Posts
    47

    "/"

    i understand you only desire to send information ( or in other words : parameters ) to a dos program...
    if so ..the command$ function would be useless to you because it's use only in handy from within vb.
    the reason your parameters didn't work , is because you forgot the "/" mark
    if you want to call a program : "c:\autoturbo.exe"
    then you need to write this : shell(..."c:\autoturbo.exe" /p)
    notice the "/p"
    this might tell the program to print something or whatever
    go it?
    then again , i dont know how dos programs translates the parameters .. and that's why i'm not possitive about what i'm telling ya..but try it out ...maybe it'll work
    DealMan

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