Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Say I use "shutdown -s -f -t 13600" to initiate a scheduled shutdown.

In Windows XP, I would always see a dialogbox alerting me of the impending shutdown.

In Windows 7 however it shows a popup in the system tray, which disappears after a couple of seconds.

How do I query, or enable a dialog like Windows XP for me to know when the shutdown is going to happen?

share|improve this question
add comment

3 Answers

I've found a way.

If instead of using shutdown -s -f -t 13600

you use shutdown -s -f -t 13600 -c "13600"

The -c option adds a comment to the shutdown event logged by Windows Event Viewer

Your comment of "13600" will be visible in the Event Viewer as seen in the red oval: event viewer showing system events

To see this view yourself:type Event Viewer in the start menu and go to Windows Logs -> System and you will see a list of system events.

Any events with an Event ID of 1074 will be a delayed shutdown.

So what we want is some code that gets the last 1074 event, looks up the value in the comment of the event and adds that value (in seconds) to the time the event was created, thus giving the shutdown time.

I made a function for Windows PowerShell (comes with Windows 7) that does that:

function nextShutdownTime
{
    $events = Get-WinEvent -FilterHashtable @{logname="system"; id=1074}
    $event = $events[0]
    $eventXML = [xml]$event.ToXml()
    return $event.TimeCreated.addSeconds([int]$eventXML.Event.EventData.Data[5])
}

Just add it to your PowerShell Profile and in PowerShell just run the command nextShutdownTime to see the expected shutdown time.

share|improve this answer
add comment

I just spent about an hour trying to make this work exactly as you wanted somehow. I experimented, and searched and searched, but I could not get it perfect, but I was able to come up with something.

I tried every combination of shutdown (-i -c -d options), but nothing.

I also experimented with the GUI interface after the -i option.

I also tried changing the balloon time display so it would stay down in the systray longer, but still, even that disappears.

The closest I go with with this sample command: shutdown -i -r -t 300

I think the fact is that they simply changed the way it works, and I don't think there is any way around it 100%, but the -i now brings up a dialog box, whereas it used to bring up the screen you wanted. When I used the -i in Windows 7, I had to fill out the box, and here was the result:

enter image description here

Then I hit Enter and got this:

enter image description here

I tested, and it seems that the upper value you can put in the "Display warning for X Seconds" is only 600, despite the fact you can enter up to 999 (very strange programming).

share|improve this answer
    
I just realized that it still does not do the countdown thing either. –  KCotreau Jul 30 '11 at 16:13
    
Yeah, the server 2008 shutdown along with the xp shutdown only allow you up to 600 seconds. The windows 7 and 2008R2 allow something like up to 10 years. –  surfasb Jul 31 '11 at 5:16
add comment

Unfortunately the native shutdown program in Windows 7 does not provide a countdown dialog (or a cancel button).

If you need these you can use an HTA window, which can have text, images, a countdown and a cancel button.

Here is an example: HTA Script - Shutdown script and warning message

Shutdown dialog

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.