Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding command line arguments to VB.Net application

I have a windows forms based application made by another programmer and I need to add a few command line switches to it's primary output exe so that I can pass arguments like:

program.exe -reinitialise or program.exe -sync

I have found some docs online but all seem to be in C# and are for command line only programs.

This program installs via an .msi and the .exe is only constructed at the end.

So my questions are:

  1. How do I add command line switches to a VB.Net application?

  2. Where/What form do I add the parser to so that the primary output .exe accepts the args?

like image 480
Myles Gray Avatar asked Aug 28 '11 00:08

Myles Gray


People also ask

How do I add command line arguments in Visual Studio?

To set command-line arguments in Visual Studio, right click on the project name, then go to Properties. In the Properties Pane, go to "Debugging", and in this pane is a line for "Command-line arguments." Add the values you would like to use on this line. They will be passed to the program via the argv array.

How do I add command line arguments in app?

Right-click on the shortcut and choose Properties. In the target-field add command line parameters after the program file name. For example: %SystemRoot%\system32\notepad.exe C:\test1. txt.


1 Answers

Similar to C/C#, you get them as an array. Different from C/C#, you obtain them as a read-only property from the application itself (My.Application.CommandlineArgs)

http://msdn.microsoft.com/en-us/library/z2d603cy(v=vs.80).aspx#Y550

Code sample on that page (for VB) should show you what you need i think...

like image 151
Brandon Langley Avatar answered Sep 29 '22 23:09

Brandon Langley