0

I want to execute a batch file from c#.net code. A batch file may take unknown number of the command line arguments. I want to pass these arguments from c# code.

How this can be achieved through c#?

Edit : I have written following code

    ProcessStartInfo psi = new ProcessStartInfo(filePath);
    psi.WindowStyle = ProcessWindowStyle.Hidden;
    psi.CreateNoWindow = true;
    psi.Arguments = "some value";
    Process proc = new Process();
    proc.StartInfo = psi;
    proc.Start();            
AMissico
  • 21,470
  • 7
  • 78
  • 106
Sagar
  • 454
  • 10
  • 22

1 Answers1

0

Look at http://www.dotnetperls.com/process-start-vbnet for a good introduction. Specifically, see the "Run executable" example at the bottom.

Here is the search query I used http://www.bing.com/search?q=command+line+parameters+process+start, if you need more examples.

AMissico
  • 21,470
  • 7
  • 78
  • 106
  • I got the answer. To pass the multiple arguments I just set used following code line. ProcessStartInfo psi = new ProcessStartInfo(filePath); psi.WindowStyle = ProcessWindowStyle.Hidden; psi.Arguments = "value1" + "value2" + "value3"; – Sagar Jun 02 '12 at 06:23
  • @sagar You need spaces between each argument. You can use `string.Join(" ", values)` to easily join a collection of data, with a certain delimiter. However, in the example you provided in your last comment, you can simply do `psi.Arguments = "value1 value2 value3;` – SimpleVar Jun 02 '12 at 07:01