Hoping you can help me with the code below, when a user logs into a certain PC the program below runs. After the process the runs the exe closes I want the PC to logoff, the myProcess_Exited method below doesn’t run, can you spot any problems?
Thanks
Steven
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();
}
}
The below one works perfectly fine.