Results 1 to 7 of 7

Thread: [RESOLVED] command line arguments

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    Resolved [RESOLVED] command line arguments

    i think these are command line arguments, im not sure:
    prog1.exe /s /?

    Id like to know how to code some into my program? Please leave a link that explains them and shows how to implement them.

    thanks in advance chris1990
    If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.

    If you fail, try and try again, its the only way to success.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: command line arguments

    What specific arguments are you interested in?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    Re: command line arguments

    I've read somewhere a few months ago that you can run parts of your code by using arguments. So parts of code in my program.
    If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.

    If you fail, try and try again, its the only way to success.

  4. #4
    Member
    Join Date
    Feb 2005
    Posts
    36

    Re: command line arguments

    Yes, if you call your program from command prompt and you pass arguments as such:

    prog1.exe argument

    then the argument is automatically saved in vb as the constant variable: Command. So, if you want your msgbox.exe program to message whatever you type in as an argument then this would be the program:
    vb Code:
    1. Private Sub Form_Load()
    2.     Dim sCmd As String
    3.     sCmd = Command
    4.     MsgBox sCmd
    5.     Unload Me
    6. End Sub

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    Re: command line arguments

    My program is close.exe it has subs which include restart, log off, shutdown. I was hoping to run the subs in the program from another so i could use something likethis to restart the PC:
    vb Code:
    1. Shell "close.exe /restart"
    If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.

    If you fail, try and try again, its the only way to success.

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: command line arguments

    Assume that this is your program

    Code:
    Option Explicit
    
    Private Sub Form_Load()
    
        CallByName Me, Command, VbMethod
    End Sub
    Public Sub restart()
    MsgBox "restart"
    End Sub
    
    Public Sub shutdown()
    MsgBox "shutdown"
    End Sub
    Then from a program

    Shell "C:\temp\project1.exe restart"

    or from Start|Run you could do

    C:\temp\project1.exe restart

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    Re: command line arguments

    thanks
    If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.

    If you fail, try and try again, its the only way to success.

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