Creating custom command line switches?

R

Rico

Hello,

I'm new to VB.net and I have an application that I would like to open up in
one of two different modes depending on a command line switch. The code
will run as a scheduled task in Windows every fifteen minutes. I'd like to
supply a command line switch (like "C:\Program Files\My Program\MyProg.exe
/Auto") so the program will run without displaying the user interface. BUT,
I'd like to show the interface if the command line switch is excluded, and
not run the auto code.

I've looked through the help file and on google and all I seem to come up
with his running the VS IDE (or access) in different modes using the command
line switches.

Any help would be greatly appreciated.

Thanks!
Rick
 
J

Jim Wooley

I'm new to VB.net and I have an application that I would like to open
up in one of two different modes depending on a command line switch.
The code will run as a scheduled task in Windows every fifteen
minutes. I'd like to supply a command line switch (like "C:\Program
Files\My Program\MyProg.exe /Auto") so the program will run without
displaying the user interface. BUT, I'd like to show the interface if
the command line switch is excluded, and not run the auto code.

Rather than having the application start with a form, use a Sub Main to check
the values in My.Application.CommandLineArgs for the presence of
your "/Auto" switch. If it is there, do your functioning and exit. Otherwise,
show your form using Application.Run(MyForm) which will hand procesing off
to your main form until it is closed.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
 
R

Rico

EXCELLENT! Thanks Jim!

Jim Wooley said:
Rather than having the application start with a form, use a Sub Main to
check the values in My.Application.CommandLineArgs for the
presence of your "/Auto" switch. If it is there, do your functioning and
exit. Otherwise, show your form using Application.Run(MyForm) which will
hand procesing off to your main form until it is closed.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
 
R

Rico

Hi Jim,

Maybe I spoke too soon. Im using VB.net 2003 if that makes a difference. I
was able to find "CommandLineArguments" in the help file, which references
the envDTE object which leads to more and more confusing documentation. The
reason I say that is the microsoft example is somewhat vague. Here is the
code they they provided;

Sub CommandLineArgumentsExample()
MsgBox(DTE.CommandLineArguments)
End Sub

And here is the code I had to put together

Private Sub test()
Dim DTE As EnvDTE.DTE

Debug.WriteLine(DTE.CommandLineArguments)

End Sub

I'm having a hell of a time getting any of this to work. I'm I travelling
down the wrong road (based on the differences between your CommandLineArgs
and MS's CommandLineArguments). Any further direction would be great!

Thanks Jim,

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top