希望您可以通过下面的代码帮助我,当用户登录到某台 PC 时,下面的程序会运行。进程运行后exe关闭我希望PC注销,下面的myProcess_Exited方法没有运行,你能发现任何问题吗?
谢谢史蒂文
private void myProcess_Exited(object sender, System.EventArgs e)
{
System.Diagnostics.Process proc1 = new System.Diagnostics.Process();
proc.StartInfo.FileName = "C:\\windows\\SysWOW64\\shutdown.exe";
proc1.StartInfo.Arguments = "/l";
proc1.StartInfo.UseShellExecute = false;
proc1.StartInfo.RedirectStandardOutput = false;
proc1.Start();
Application.Exit();
}
private void Form1_Load(object sender, EventArgs e)
{
System.Diagnostics.ProcessStartInfo p = new System.Diagnostics.ProcessStartInfo(@"K:\App\pc\stub.exe");
p.Arguments = "-RunForever";
proc = new System.Diagnostics.Process();
proc.StartInfo = p;
proc.EnableRaisingEvents = true;
proc.Exited += new EventHandler(myProcess_Exited);
proc.Start();
}
}