4

I have an application running on Windows 7 Embedded, and it needs to communicate to an external resource whenever the system is shutting down OR rebooting. My logic is different depending on whether or not the system is shutting down permanently vs. shutting down as part of a reboot.

From what I see, there's a few comments suggesting that it is not possible to accurately determine shutdown vs. reboot, but I need a little more evidence (or MSDN doc would be nice).

This post gives a somewhat hackish solution to distinguishing between the two, but for the most part is not reliable: Tell reboot from shutdown on Windows Server 2008.

On this post: Is there a way in c# to detect a Windows shutdown/logoff and cancel that action (after asking the user) ...one of the commenters suggests that it is NOT possible to detect the difference between reboot and shutdown, at all.

Does anyone have a more authoritative answer to this problem?

Community
  • 1
  • 1
warriorpostman
  • 2,268
  • 2
  • 16
  • 26
  • possible duplicate of [How to detect Windows shutdown or logoff](http://stackoverflow.com/questions/6799955/how-to-detect-windows-shutdown-or-logoff) – Cody Gray - on strike Jan 19 '12 at 18:53
  • This is more of a clarification question @Cody Gray. I'm specifically trying to determine the difference between shutdown and reboot. The post you cited talks about shutdown vs. logoff. – warriorpostman Jan 19 '12 at 19:15
  • 2
    There's no way to get Windows to make you a promise like that. It cannot possibly guarantee that a reboot won't actually be a shutdown. It can't make that guarantee, it won't be running when the critical moment arrives. In this kind of scenario, you need to be able to resume properly when somebody trips over the power cord. When that's in place, you really don't care anymore about how the machine got shutdown. Shouldn't anyway. – Hans Passant Jan 19 '12 at 20:20

1 Answers1

0

Both for shutdown and reboot, the main command is same just the different in the arguments. For shutdown, it is shutdown -s For reboot, it is shutdown -r

You may try to check for the arguments

Anirban Saha
  • 51
  • 1
  • 14