I want to run some cmd command from c# code. So I am using process class like as following:
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = "CMD";
p.StartInfo.Arguments = "/C IPCONFIG.....";// here I want to pass multiple arguments but how can I pass multiple aruments please give me any idea about it.
I want to pass like p.StartInfo.Arguments = "/C IPCONFIG Tree".

VulpesPosted Apr 19, 2014, 11:46 AM
To execute multiple commands you can use a batch file but you can also separate the commands with the & symbol (or && if you only want to run the second command if the first was successful).
So this should work:
p.StartInfo.Arguments = "/C ipconfig & tree";
Sourabh SomaniPosted Apr 20, 2014, 8:12 PM
Sourabh SomaniPosted Apr 19, 2014, 10:02 AM
I am generating one batch file(.bat) and I am doing
VulpesPosted Apr 16, 2014, 6:19 AM
If a particular argument contains embedded spaces, then it should be enclosed in double quotes.