Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want a custom confirmation message when the user shuts down Windows, but there should be some points:

  1. When the user is trying to shut down, it should show the confirmation message.
  2. If the user hits OK, then it will be shut down.
  3. If they hit the Cancel button, then also the window should shut down and some unique value should be made in a database (SQL server).
share|improve this question
Please identify which Windows version? I'm sorry you completely lost me on last point what does it mean? Please be more clear. – avirk Sep 10 '11 at 9:29
ok avirk is applicable all window like xp,window server 2003 ,windows7 and last point is when user hit cancel button then also window shut down and some unique number go in database – Atul Sep 10 '11 at 9:34
And what kind of those numbers are? – avirk Sep 10 '11 at 9:37
any unique number like 123145 – Atul Sep 10 '11 at 9:39
That kind of behaviour is up to each application to implement, doing it that way is easy if you have the sourcecode. There is nothing you can do to intercept an applications shutdown (without doing some deep integration into explorer.exe and probably windows itself (if it's possible at all)) – Nifle Sep 10 '11 at 10:02
up vote 6 down vote accepted

Why would you need it?

Windows has already a built-in feature called shutdown event tracker. It is enabled by default on server OSes, and you can also enable it through the group policies (for example with gpedit.msc) on desktop versions of Windows.

A screenshot of Local Group Policy Editor showing "Display Shutdown Event Tracker" option

It gives you the ability to:

  1. Avoid that the user shuts down the machine by mistake by showing the dialog box like: A screenshot of a Shut Down Windows dialog under Windows 2008
  2. Track the shutdown events through Event Viewer with a more detailed view.

For example:

  • Without the event tracker enabled, you have:

Kernel-Power:109 The kernel power manager has initiated a shutdown transition.
Kernel-General:13 The operating system is shutting down at system time ‎2011‎-‎09‎-‎10T00:23:20.247232500Z.

  • With Shutdown Event Tracker, you have:

USER32:1074 The process Explorer.EXE has initiated the restart of computer <Computer name> on behalf of user <Domain name>\<User name> for the following reason: Loss of network connectivity (Unplanned)
Reason Code: 0x4050014
Shutdown Type: restart

From here, if you're a developer or if you're able to hire one, you can easily create a tool which will scan Windows Events and import the significant information into your database, including the user who started the shutdown, or the reason.

share|improve this answer
ok mainma thnx for your valuable suggestion and advise – Atul Sep 10 '11 at 10:14
but that conformation pop up message how will i show? – Atul Sep 10 '11 at 10:21
@Atul: sorry, my answer was unclear on this point. See the last edit. – MainMa Sep 10 '11 at 10:30
ok mainma .... thnx your suggestion it is show confirmation message when shut down window? and how will one unique value go in database ?? – Atul Sep 10 '11 at 10:36
"Does it show confirmation message when you shut down windows?": yes. "How will one unique value go in database?": like I said in the last paragraph of my answer, it's up to you to build a tool which will extract data from Windows Event Log, transform it, and load it into a database. – MainMa Sep 10 '11 at 10:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .