5

When I issue an ACPI shutdown command to a Windows XP guest machine from the host VM server, I want Windows to shutdown.

The problem is, Windows always wants to ask some question or another, rather than just shutting down. I need shutdown to be reliable, no matter what is running or going on, so I can automate shutdowns from the host machine. But I want it to be as graceful as possible, rather than just pulling the plug.

Some problems:

  • If a user is logged in, ACPI shutdown causes a box to appear that says, "are you sure you want to shutdown while other users are logged in"? And this prevents shutdown until someone connects to the machine and clicks "yes". In this case, it should try its best to gracefully log out all users, using force if necessary, and then shutdown without promoting.

  • Busy or non-responding programs or programs asking to save data can prevent Windows from shutting down until a user answers a prompt. This should attempt to save data, wait maybe 30 seconds for non-responding programs, but should get aggressive with stubborn programs. "nope, time's up! 3,2,1, Goodbye!"

Is there a registry setting that I can change from:

ACPI_Shutdown: "Shut down if Windows feels like it"

to

ACPI_Shutdown: "Just do it. Kill programs, bump users, try to be graceful about it, but when I come back, I expect you to be off."

This should respond to the ACPI shutdown command, and not be a script on windows, unless that script is triggered by the ACPI power button. I'm hoping this can be changed with registry options.

3
  • C:\>shutdown -s -f -t 00 -m \\vm doesn't work? Mar 25, 2012 at 3:27
  • Can you attach shutdown -s -t 0 to the power button event? On the host machine, the command is virsh shutdown xpvm where xpvm is the machine name. Then the host sends a power button signal (ACPI) to the guest. Linux guest machines respond by shutting down immediately. I'd like the same behavior on Windows guests too.
    – Nick
    Mar 27, 2012 at 19:35
  • If the VM is on the same network as the host, and the account on the host has credentials, then the shutdown -m can target a remote machine (the VM). Do you have to use 'power button' to shutdown the VM? Why not get the OS (XP) to shut itself (and the VM) down? Keep in mind: I was assuming a Windows host, I realize shutdown.exe is not triggered by ACPI on the target machine, and that these are comments, not answers. ;) Mar 27, 2012 at 22:32

3 Answers 3

1

It would probably be better if you remoted into the VM somehow and issued a shutdown -s -t 0 command which will begin shutdown without prompting the user.

You can use Sysinternal's PsExec to do this from a script or batch file.

Alternatively you can add a virtual serial port to your VM, enable the Windows XP Special Administration Console, and issue the command via the SAC. Issuing commands via a script/batch file to the SAC will be more complex, but you would be able perform the shutdown even if the XP instance's network isn't working.

Update: This may be a new thing in Vista/7 - looks like the shutdown command has a /p flag that, according to the command help "Turn off the local computer with no time-out or warning."

So try a shutdown -s -p -f and see what you get. - Never mind, just hopped on my xp machine and it doesn't have the /p option ...

1
  • Can you attach shutdown -s -t 0 to the ACPI power button event? Or attach a script to the power button?
    – Nick
    Mar 27, 2012 at 19:37
1

For Windows XP I'm using following command on my Ubuntu host:

VBoxManage guestcontrol "WinXPVM" execute --image "C:\Windows\system32\shutdown.exe" --username put_username_here --password put_password_here -- -s -f -t 10

Last argument is time before actual shutdown starts - if you want it to start right away you can change it to -t 0

Hope this will help anyone :)

0

It looks like there are a few registry, group policy values that allow Windows XP/7 to handle an ACPI PowerDown event without requiring additional interaction with the OS. It might also be necessary to make sure the Control Panel/Power Options are set to shutdown for power button, as well as monitor sleeping disabled.

Windows XP

Add/Set the following registry keys/values

  • [DWORD] HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system\shutdownwithoutlogon=1
  • [DWORD] HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\ShutdownWarningDialogTimeout=1

If the warning dialog doesn't time out, the following can be added (warning *)

  • [DWORD] HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Error Message Instrument\EnableDefaultReply=1

* this will cause windows to automatically reply to additional dialogs, such as force active user logoff

Windows 7

Add/Set the following group policy keys/values

  • Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options\Shutdown: Allow system to be shut down without having to log on=Enabled
  • Computer Configuration\Administrative Templates\System\Display Shutdown Event Tracker=Disabled

ref, ref

You must log in to answer this question.

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