shutdown.exe
to implement this function.RuntimeBroker.exe
), Windows waits for the resident process to finish sending the record (according to HKCU\Control Panel\Desktop\HungAppTimeout
).When I shut down Windows with shutdown.exe
, it doesn't refer to HKCU\Control Panel\Desktop\HungAppTimeout
and kills the resident process forcibly before it finishes sending the record.
Is there any way (like a PowerShell cmdlet or a command included in Windows) to shut down Windows programmatically and wait for the termination of the resident processes gracefully before the shutdown?
Based on @An-dir's advice, I have tested some ways to shutdown Windows:
# | How to shutdown | What is executed | Wait for HungAppTimeout |
---|---|---|---|
1 | shutdown from Start Menu | RuntimeBroker.exe |
Yes |
2 | run shutdown.exe |
shutdown.exe |
No |
3 | run SlideToShutDown.exe |
SlideToShutDown.exe |
Yes |
4 | run Stop-Computer cmdlet |
WmiPrvSE.exe |
Yes |
5 | shut down from the lock screen | winlogon.exe |
No |
6 | Alt+F4 on Desktop | Explorer.exe |
Yes |
For my purpose, Stop-Computer
and SlideToShutDown.exe
look suitable.