C # Cancel Windows Shutdown Programmatically
I found on the internet that I can schedule windows to start on shutdown:
private void button1_Click(object sender, EventArgs e)
{
// Shutdown
Process.Start("shutdown", "/s /t 10");
}
private void button2_Click(object sender, EventArgs e)
{
// Cancel Shutdown
Process.Start("shutdown /a");
}
This way I have attached to the button even if it calls above. Is there a way to bind a command to another button that cancels this completion?
I have search and hideout, I found something useful, I found something like
Process.Start("cmd.exe", "shutdown /a");
or
Process.Start("shutdown /a");
But none of them work.
Calling Process.Start ("shutdown / a"); leads to
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
source to share
Process.Start ("shutdown", "/ a");
will work when scheduled shutdown with
Process.Start ("shutdown", "/ s / t 60");
but it does not cancel a shutdown that has already been initiated (i.e. 60 seconds have passed).
It's just using the built-in commands in windows: http://technet.microsoft.com/en-gb/library/bb491003.aspx
source to share