Home All Groups Group Topic Archive Search About

Creating custom command line switches?

Author
27 Jul 2006 9:00 PM
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

Author
27 Jul 2006 9:26 PM
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
Author
27 Jul 2006 9:54 PM
Rico
EXCELLENT!  Thanks Jim!

Show quoteHide quote
"Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message
news:24f81e8f7d008c87fb8fa9545d7@msnews.microsoft.com...
>> 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
>
>
Author
27 Jul 2006 10:38 PM
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




Show quoteHide quote
"Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message
news:24f81e8f7d008c87fb8fa9545d7@msnews.microsoft.com...
>> 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
>
>