Passing an argument to cmd.exe

前端 未结 5 1604
春和景丽
春和景丽 2020-12-01 20:47

I am attempting to ping a local computer from my C# program. To accomplish this, I\'m using the following code.

System.Diagnostics.ProcessStartInfo proc = ne         


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 21:15

    To call the ping command directly, do as you have in your question, but substitute cmd.exe with ping.exe:

    ProcessStartInfo proc = new ProcessStartInfo();
    proc.FileName = @"C:\windows\system32\ping.exe";
    proc.Arguments = @"10.2.2.125";
    Process.Start(proc);
    

提交回复
热议问题