Background
- 我正在编写一个程序以在指定时间关闭Windows。我正在使用
shutdown.exe
来实现此功能。 - 在我的计算机中,有一个常驻进程来记录系统活动,并在关闭 Windows 时将记录发送到服务器。当您从开始菜单关闭 Windows 时 (
RuntimeBroker.exe
),Windows 等待常驻进程完成发送记录(根据HKCUControl PanelDesktopHungAppTimeout
)。
问题
当我用shutdown.exe
关闭Windows时,它不是指HKCUControl PanelDesktopHungAppTimeout
,并在完成发送记录之前强制杀死常驻进程。
问题
有没有办法(如PowerShell cmdlet或Windows中包含的命令)以编程方式关闭Windows并在关闭之前优雅地等待常驻进程的终止?
根据@An-dir的建议,我测试了一些关闭Windows的方法:
# | 如何关机 | 执行什么 |
---|
关闭 | RuntimeBroker.exe |
是 |
运行shutdown.exe | shutdown.exe | 否 |
运行SlideToShutDown.exe | SlideToShutDown.exe | 是 |
运行Stop-Computer cmdlet | WmiPrvSE.exe | 是 |
从锁定屏幕关闭 | winlogon.exe | 否 |
Alt+F4 | Explorer.exe | 是 |