Link to home
Start Free TrialLog in
Avatar of SETP
SETP

asked on

Command Line Arguments

How can I read the command line arguments that a VB.NET 2003 program is launched with? For example, if I have a program call "SuperCalc.exe" and it is run as follows:

"SuperCalc.exe /r"

How can I detect from code that the command-line argument "/r" was used?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of flavo
flavo
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of arif_eqbal
arif_eqbal

Yes flavo you are right,

There's another way however which is this

Dim Str() As String = Environment.GetCommandLineArgs()
if Str(1) = "/r" then
  'Do Something
End If

Here you need not Split as we get an array anyway
the following is a good article on this topic

http://www.devx.com/dotnet/Article/10115/1763
Avatar of SETP

ASKER

Thanks! Didn;t know there was an Environment class. Nice...
Glad to help once again :-)

Dave