The entry point for a Windows application in the .Net Framework is a static
method called "Main" (not sure what the VB.Net implementation is, but it is
similar). The Main method can take a list of arguments, which are
command-line arguments. So, for example, here is some code for a C# (sorry)
program I wrote that takes command-line arguments:
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string docToOpen = null, saveFilePath = null;
bool refresh = false;
string arg;
Utilities.SetEventLogSourceAndName(
Properties.Settings.Default.EventLogSource,
Properties.Settings.Default.EventLogName);
if (args.Length > 0)
{
// find the file path to open, if it exists
for (int i = 0; i < args.Length; i++)
{
arg = args
.Trim();
if (arg.StartsWith("/"))
{
if (arg.StartsWith("/sfp:",
StringComparison.CurrentCultureIgnoreCase) ||
arg.StartsWith("/saveFilePath:",
StringComparison.CurrentCultureIgnoreCase))
saveFilePath = arg.Substring(arg.IndexOf(':') + 1);
else if (arg.StartsWith("/refresh")) refresh = true;
}
else if (File.Exists(arg)) docToOpen = arg;
}
if (docToOpen != null && saveFilePath == null)
saveFilePath = Path.GetDirectoryName(docToOpen);
Application.UseWaitCursor = true;
if (docToOpen != null || saveFilePath != null)
Application.Run(new PrintManager(docToOpen, saveFilePath,
refresh));
else
Application.Run(new PrintManager());
}
else
Application.Run(new PrintManager());
}
--
HTH,
Kevin Spencer
Microsoft MVP
Logostician
http://unclechutney.blogspot.com
There is a madness to my method.
Milan said:
How do you pass in arguments from the command line to
a .Net windows app.
Senario: vb.net application should be able to execute from command
prompt by passing login and password and should be able to execute
process form (with his parameter)
User should not be able to see GUI
Milan