Background
- I am writing a program to shut down Windows at the specified time. I am using
shutdown.exeto implement this function. - In my computer, there is a resident process to record system activity and send the record to a server when shutting down Windows. When you shut down Windows from the start menu (
RuntimeBroker.exe), Windows waits for the resident process to finish sending the record (according toHKCU\Control Panel\Desktop\HungAppTimeout).
Problem
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.
Question
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:
RuntimeBroker.exeshutdown.exeshutdown.exeSlideToShutDown.exeSlideToShutDown.exeStop-ComputercmdletWmiPrvSE.exewinlogon.exeExplorer.exeFor my purpose,
Stop-ComputerandSlideToShutDown.exelook suitable.