Creating a Command Line Paremeter for an Application

djfurthur

Newcomer
Joined
Jun 24, 2003
Messages
10
I have an application that automates downloads. Sometimes, i want it to download the entire set of available downloads. Sometimes, though, i only want it to download a specific subset. I was thinking about using some sort of command line paremeter with the application to do this. can anyone tell me how to accomplish this in VB .NET?
 
To get the command line parameters passed into your application use those:
Visual Basic:
System.Environment.CommandLine() 'returns all params
'or
System.Environment.GetCommandLineArgs() 'returns params separated
 
First one will return the exe path and all the parameters. The second one will return an array of strings, that were created by separating every commend by a space. The first member of that array will be your exe path and name, and next members will hold the params.
 
From reading the help file, this sounds llike a method to call a program from inside another visual basic program. Do i just have this thing completley backwards?

chris
 
You can start another program from a .NET application, you can do that using System.Diagnostics.Process. Command Line wont start anything for you by itself, you have to read the parameters and do whatever you do for each one.
 
So i start "program.exe 1", and somewhere in the program, i say

Dim arguments As [String]() = Environment.GetCommandLineArgs()

so....

Arguments[0] = 'program.exe'
Arguments[1] = '1'

have i got the basic idea?
 
well, that is what i get for being a c coder trying to cram a bunch of vb into my head :)

thanks for the help, i will look into this next week.

chris
 
Back
Top