Process[] process = Process.GetProcessesByName("KVMonXP.kxp");
int pid = process[0].Id;
MessageBox.Show(pid.ToString(), "");
ProcessStartInfo cmd = new ProcessStartInfo();
cmd.FileName = "cmd";
cmd.Arguments="taskkill /pid "+pid +"/t";
cmd.WindowStyle = ProcessWindowStyle.Maximized;
Process.Start(cmd);
我把这段代码放到窗体的载入事件里,编译通过,且可以正常运行,但就是不执行"taskkill /pid "+pid +"/t"命令,而是只弹出CMD窗口来,请问要怎么样才能让CMD自动运行那命,谢谢!
int pid = process[0].Id;
MessageBox.Show(pid.ToString(), "");
ProcessStartInfo cmd = new ProcessStartInfo();
cmd.FileName = "cmd";
cmd.Arguments="taskkill /pid "+pid +"/t";
cmd.WindowStyle = ProcessWindowStyle.Maximized;
Process.Start(cmd);
我把这段代码放到窗体的载入事件里,编译通过,且可以正常运行,但就是不执行"taskkill /pid "+pid +"/t"命令,而是只弹出CMD窗口来,请问要怎么样才能让CMD自动运行那命,谢谢!
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
//p.StartInfo.CreateNoWindow = true; p.Start();
p.StandardInput.WriteLine("del d:\\123.txt");
p.StandardInput.WriteLine("exit");