I've been using Remote Desktop Connection to get into a workstation. But in this environment, I cannot use the power options in Start Menu. I need an alternative way to shutdown or restart.
How do I control my computer's power state through the command line?
No one has mentioned
-m
option for remote shutdown:Also:
-r
parameter causes a reboot (which is usually what you want on a remote machine, since physically starting it might be difficult).-f
parameter option forces the reboot.Original answer: Oct. 2008
You also got all the
"serie:rundll32.exe shell32.dll
"(see update below)
rundll32.exe user.exe,**ExitWindows**
[Fast Shutdown of Windows]rundll32.exe user.exe,**ExitWindowsExec**
[Restart Windows]where
n
stands for:LOGOFF
SHUTDOWN
REBOOT
FORCE
POWEROFF
(can be combined -> 6 = 2+4
FORCE REBOOT
)Update April 2015 (6+ years later):
1800 INFORMATION kindly points out in the comments:
Raymond CHEN wrote:
(oops)
And to make it crystal-clear:
Another small tip: when going the batch file route, I like to be able to abort it in case I run it accidentally. So the batch file invokes the shutdown but leaves you at the command prompt afterwards.
Plus, since it's on a timer, you get about the same thrill as you do when hunting in The Oregon Trail.
If you are on a remote machine, you may also want to add the -f option to force the reboot. Otherwise your session may close and a stubborn app can hang the system.
I use this whenever I want to force an immediate reboot:
For a more friendly "give them some time" option, you can use this:
As you can see in the comments, the -f is implied by the timeout.
Brutus 2006 is a utility that provides a GUI for these options.
When remoted into a machine (target is Windows XP anyway; I am not sure about target Windows Vista), although Shutdown on the start menu is replaced by Disconnect Session or something like that, there should be one called 'Windows Security' which also does the same thing as Ctrl + Alt + End as pointed to by Owen.
I would write this in Notepad or WordPad for a basic logoff command:
This is basically the same as clicking start and logoff manually, but it is just slightly faster if you have the batch file ready.