Pass paramters to applications when executing?

Hi,

How do you pass a parameter to an application when executing an application

E.g. "MyApp.exe -parameter".

Thanks,

Weiran.



Answer this question

Pass paramters to applications when executing?

  • zacksz

    Hello

    Are you working with Console Applications In Console Applications you can send any information by the help of command line arguments.


  • Michael K Campbell

    Check this link for the implementation

    http://msdn2.microsoft.com/en-us/library/acy3edy3(VS.80).aspx

  • Sh Dr Cn

    Create a shortcut to the exe and add the args to the target line of the shorcut's properties.

  • cevans

    Sorry I don't think I was very clear. I know how to send the parameters, but how do you read them in the application

    I'm also using a Windows Forms app not console.

    Thanks.


  • M-Star

    Ahh of course! I've done it in Java before too, but somehow completely forgot!

    Thanks!


  • cyphorous

    Commandline parameters are passed into the string array of the main-method:

    static void Main(string[] args)

    where you can access them just like you would do with any other array.


  • Pass paramters to applications when executing?