Media Center | Abort System Shutdown

I initially wrote this for a tgb member but I've since used it at home as well. The add-in will run in the background, including extenders, and if there is a scheduled system shutdown or reboot Media Center will detect the pending shutdown and give the user the option of aborting it.

Abort System Shutdown

Note:

  • Only works w/ scheduled shutdowns. Scheduled shutdowns are those initiated with timeout value using InitiateSystemShutdown\InitiateSystemShutdownEx API. A common way to schedule a reboot is using the shutdown command. i.e. shutdown /r /t 120 /c "Rebooting in two minutes". I initial did write to handle all system shutdowns and managed to get it to work but in Vista\W7 Microsoft changed the APIs to purposely prevent aborting shutdowns. I'll go more into that later if anyone is interested, I did some fun code workarounds to get around not being able to create visible windows in Media Center and the Window Message handlers.

  • This runs as a background add-in. Background add-ins have a load delay. It is approximately 8 seconds on my system. So if a command is scheduled in that period it won't be picked up.

  • With the shutdown command you can add an optional comment. If there is a comment entered it is appended to the dialog box text as well.