?
Solved

Command Line Arguments

Posted on 2005-05-12
5
Medium Priority
?
2,692 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:SETP
5 Comments
 
LVL 34

Accepted Solution

by:
flavo earned 2000 total points
ID: 13984735
I dont have VS .Net on me, but i almost sure this is it

       Dim cmdArg As String = Environment.CommandLine()
       Dim cmdReturn As String()
       cmdReturn = cmdArg.Split(" ", 3)
       MsgBox(cmdReturn(1))

Dave
0
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 13984778
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
0
 
LVL 9

Expert Comment

by:checoo
ID: 13984914
the following is a good article on this topic

http://www.devx.com/dotnet/Article/10115/1763
0
 

Author Comment

by:SETP
ID: 13986010
Thanks! Didn;t know there was an Environment class. Nice...
0
 
LVL 34

Expert Comment

by:flavo
ID: 13986408
Glad to help once again :-)

Dave
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question