Jump to content

Reboot vs Shutdown

Recommended Posts

I am looking for a solution to tell me what a user selects from the Windows shutdown menu.

1) Logoff

2) Restart

3) Shutdown

4) Shutdown and install updates

(Not worried about hibername, etc.)

With this, I can select good times to do maintenance, etc.

Using WM_ENDSESSION, I can tell if the system is going to logoff or if the system is being (shutdown or restarted)

(ie does not inform the window if the system is being shutdown or restarted, just that one of the two is happening.)

The system shutdown script, as commonly edited by gpedit, also does not distinguish between a shutdown or restart.

Finally, there is a registry entry that the logoff screen changes to save the choice of the user, so that it is default next time.

It appears that this was removed in WinXP.

Does anyone know of a function in the WinAPI or WMI that may provide that information?

Other ideas?

I would like to use this for WinXP, WinVista, Win7.

Primarily interested in the user's choice. If Automatic Updates or MSI initiates a reboot then I am not particularly concerned about that.


Link to comment
Share on other sites


One way of doing this to use a WMI Monitor on the Eventlog.

There are certain events logged for shutdown, logoff, restart etc.

Here is an example on how to setup the eventlog for Logoff/on actions


There are enough examples on the forum in how to do WMI Eventlog Monitoring, I guess



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...