aborting computer shutdown from windows service
Is it possible to abort computer shutdown from windows 开发者_开发技巧service?
Yes. You can call shutdown /a using Process.Start
static void Main(string[] args)
{
Process p = new Process();
p.StartInfo.FileName = "shutdown";
p.StartInfo.Arguments = "/r";
p.Start();
Thread.Sleep(5000);
p.StartInfo.Arguments = "/a";
p.Start();
}
The above code tells the computer to shutdown and restart, waits 5 seconds, then aborts it.
AbortSystemShutdown
I've added a sample to my answer at the similar question here
How cancel shutdown from a windows service C#
精彩评论