How to Pass Command Line Arguments using Visual Studio ?
By | September 16, 2011

You are writing one application in Visual Studio which accepts some command line parameter to do some operation. You pass command line arguments to the program when it’s been invoked  from the command line. But how did you do it from Visual Studio ?  You want to test your application and do you really want to open command prompt every time to pass the command line values. Really not. Here is the quick tip for all of you.

   Visual Studio enables a nice features where you can do this in the Project Properties window, on the Debug tab. Here is the steps to achieve this

1. Right Click on Project from Solution Explorer and Select Properties.

2. In the Project Properties Windows, Navigate to “Debug Tab”

3. You will Find the a text box “Command Line”

Well, here you can type the command line with separated by Space.

image thumb20 How to Pass Command Line Arguments using Visual Studio ?

Just write a simple console application to print the command line argument, and put a breakpoint to check the arguments,

image thumb21 How to Pass Command Line Arguments using Visual Studio ?

So, the each value separated by space has taken has a a command line argument. This will produce below output.

image thumb22 How to Pass Command Line Arguments using Visual Studio ?