Command to Call 'Turn Off Computer' Menu

Solution 1:

As others have rightfully pointed out, those commands don't work and/or shouldn't be used.

Here's an option, you can use scripting to call that shutdown dialog/menu (it just pops up the shutdown menu; it doesn't select any action). Here's a couple basics to get you started:

VBS:

CreateObject("Shell.Application").ShutdownWindows

Save as Something.vbs and run it with cscript Something.vbs.

PowerShell:

(New-Object -ComObject Shell.Application).ShutdownWindows();

You can get PowerShell 2.0 for XP (etc.) from MS here (KB968930).

These should work on all versions of XP and up (the VBS may work on Windows 2000 as well). I tested them on Windows 7 (Ultimate) and they worked.

Solution 2:

Before XP, there was a command, rundll32.exe shell32.dll,SHExitWindowsEx 1. It use to still work in XP. It doesn't work in my XP VM though. . .

Starting with XP, Microsoft includes the shutdown command, which does exactly what you want, and more. It works with remote computers, etc etc.

Edit:

There is the more popular Lock Computer command that a lot of ppl don't know about.

rundll32.exe user32.dll, LockWorkStation

edit:

http://blogs.msdn.com/b/oldnewthing/archive/2004/01/15/58973.aspx

Aparently, the above is a no no. So looks like we are stuck with PsShutdown.