Passing an Argument to a VB.Net Application which is not currently running.

Nick

New member
Joined
Nov 5, 2004
Messages
1
Programming Experience
3-5
I am going to be starting the application through a batch file which will execute the .exe of my App. I want to pass a value which tells the Application to either automatically send what it calculates, or open the form for manual submittal.

If you know or have an idea on how to pass this argument into the application at the time the app is executed please let me know so that I can store this value and act on it accordingly.
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
You could use command line parameters and use the System.Environment.GetCommandLineArgs function to read them.

Here's sample code showing how to read the command line paramters:
VB.NET:
Dim strStartupArguments() As String, intCount As Integer
strStartupArguments = System.Environment.GetCommandLineArgs
For intCount = 0 To UBound(strStartupArguments)
    MessageBox.Show(strStartupArguments(intCount).ToString)
Next
The first parameter will be the path to the executable.

An example of using the commandLine parameters (you could type this in the "Run" box or at a command prompt): c:\MyKillerApp.exe /manual
 
Top Bottom