c# - Passing an argument to cmd.exe -


i attempting ping local computer c# program. accomplish this, i'm using following code.

system.diagnostics.processstartinfo proc = new system.diagnostics.processstartinfo(); proc.filename = @"c:\windows\system32\cmd.exe"; proc.arguments = @"""ping 10.2.2.125"""; system.diagnostics.process.start(proc); 

this opens command-line window, ping not invoked. reason?

you need include "/c" argument tell cmd.exe mean do:

proc.arguments = "/c ping 10.2.2.125"; 

(you could call ping.exe directly of course. there times when that's appropriate, , times when it's easier call cmd.)


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -