Results 1 to 7 of 7

Thread: Command Line

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    If you have a DOS application that you would like to run out of VB and be able to place the required switches in how would you do it in VB.

    Example DOS app:

    dosapp -something -something else

    Any ideas would be great.

  2. #2
    Addicted Member
    Join Date
    Aug 2000
    Location
    Croatia
    Posts
    200
    Use the VB Command function


    Syntax: x = Command()


    Here's a VB Help explanation:

    quote: "Returns the argument portion of the command line used to launch Microsoft Visual Basic or an executable program developed with Visual Basic."

    Hope this helps

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    So would you place the syntax that you place in the command into a string or how would this work?

  4. #4
    Guest
    Put this code into VB.
    Code:
    Private Sub Form_Load()
        MsgBox Command
    End sub
    Now run it from DOS like this:
    C:\>MyApp.exe -Hello

    Now when you run the program, it will display a messagebox with -Hello in it.


  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    I appreciate your insight, is there a way to run it without having to manually fill in the information at the command line? This will be going out to users that have no clue how to write at the command line.

    Thanks

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Hmm, what do you want to have done brian? Have the user enter a command line, (you could as well do it with run in startmenu) or have it ask you them in runtime?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7
    Guest
    Are you looking for an example?

    Code:
    Private Sub Form_Load()
    
        Select Case Command
            Case "/k"
                MsgBox "Paramater = /kedaman"
            Case "/m"
                MsgBox "Paramater = /Megatron"
            Case Else
                MsgBox "Usage:" & vbCrLf & vbCrLf & "/k - kedaman" _
    & vbCrLf & "/m - Megatron"
        End Select
    
    End Sub
    This works as like, if a user were to go into dos, type:
    C:\MyDir\MyProgram.exe /k
    A msgbox would come up saying kedaman.
    C:\MyDir\MyProgram.exe /m
    A msgbox would come up saying Megatron.
    Case Else
    Is if nothing is if nothing or the wrong command lines are typed.

    You may also want to hide your program since Windows actually loads it.

    Notice: Your program will only work when Windows is loaded and the Windows DOS is used.

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