[英]aborting computer shutdown from windows service
是否可以从Windows Service中止计算机关机?
是。 您可以使用Process.Start调用shutdown / a
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();
}
上面的代码告诉计算机关闭并重新启动,等待5秒钟,然后中止它。
AbortSystemShutdown
我在类似问题的答案中添加了示例
如何从Windows Service C#取消关闭
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.