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".


VulpesRank #55 · 29.2K reputationPosted Apr 19, 2014, 7:46 AM EDT
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";
VulpesRank #55 · 29.2K reputationPosted Apr 16, 2014, 2:19 AM EDT
If a particular argument contains embedded spaces, then it should be enclosed in double quotes.
Sourabh SomaniRank #37 · 35.5K reputationPosted Apr 19, 2014, 6:02 AM EDT
I am generating one batch file(.bat) and I am doing
Sourabh SomaniRank #37 · 35.5K reputationPosted Apr 20, 2014, 4:12 PM EDT