开发者

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#

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜