I assume that everyone who uses Remote Desktop in Windows knows this already, but just in case…
I use Remote Desktop all the time to connect back to one or more machines on my home network. I have a single static IP address and then have terminal server running on every box behind the router on a different port. So I can connect to any of my machines remotely, by using a different port.
Being able to remote connect to any/all of my machines is huge. I consider Remote Desktop to be one of the most critical tools that I use on a daily basis.
But I occasionally find that there is something funky on one of my home machines that leads to my wanting to reboot it. For example, I sometimes run into a situation where I can’t connect to the machine from outside my network, but I can still remote from a different machine in my home network. So I remote to the “visible” machine, then remote over to the “invisible” machine. Rebooting the problem machine seems to fix the problem.
The problem with rebooting is that the Shutdown and Restart options are removed from the Start Menu when you’re connected using Remote Desktop.
But not to worry–you can still reboot the machine, just using the command prompt. Here’s the magic command (Windows 7, Vista or Windows XP):
shutdown -t 0 -r -f
That’s a “zero” after the -t option, indicating shutdown in zero seconds. The -r option indicates a restart, rather than shutdown. (Don’t forget this one)! The -f option forces all applications to terminate.
So this is a critical command, worth remembering!
Good to know. thxs!
Great worked awesome!!!!!!
Pressing Alt-F4 in remote session will bring up the menu you need to shutdown or reboot.
I think that Alt-F4 just closes the active application, no? (At least it does for me, remoted into a Win XP machine).
Ahh, I see. Ok, Alt-F4 in Windows closes the active window/application–unless none of them has focus. So Mark’s suggestion is a good one, easier than bringing up a command shell.
Simply click on the taskbar to remove focus from your current application window. Then press Alt-F4. This works in either WinXP, Win Vista or Win 7. Thanks Mark!
you can also press CTRL-ALT-END which sends a CTRL-ALT-DEL though RDC to the host
ctrl-alt-end does not give shutdown options in windows 7.
Ctrl-Alt-End does show shutdown options. As Adam said, it sends a Ctrl-Alt-Del signal, which brings up the following options in the center of the screen: Lock, Log Off, Change Password and Start Task Manager. On a “real” Win 7 machine, rather that remote connected, you’ll also get an option to Switch User.
That Ctrl-Alt-Del screen also has a red power icon in the lower right portion of the screen that includes the options: Restart, Sleep, Shut Down. On a “real” machine that you’re not remoted into, you’ll also see the Hibernate option.
I have a specific case that i need help with.. i’m using a remote desktop chain to remote desktop from a remote desktop. but i’m getting the blue screen for the windows login but without the window to put my log in credentials in. so i want to force that computer to restart. any idea how can i do that
Thanks for the tip Sean, got here from the Googlenet!
Worked on my Windows 7.
You may want to edit the comment, below, in your article to include windows 7.
“Here’s the magic command (Vista or Windows XP)”
Sean! Thanks for this entry.
I’ve tried both methods here that got mentioned and they both worked on my Windows 7 machine while I was remoted into them.
The Ctrl-Alt-End thing threw me until somebody mentioned the “power” button on the lower right. Presto.
The “Click on the Taskbar and then type Alt-F4” thing worked beautifully as well. Both of these are going into my handy commands file.
I had used the Shutdown command from the DOS prompt, but always found that klunky. The other two are quite nice and quick.
how i recover hard drive bad secteor.
It helped :)
thanks a lot!
That works great!!
Why not just keep RDP running on the default port on all the computers and have your router forward different ports to port 3395 on different computers. Seems easier than reconfiguring each computer to run RDP on a different port.
Better to set up one actual TS exposed to the outside world (using a non-standard port and hardened against intrusion), remote into that, then hop into the destination using another RDP session. That way not all your hosts have RDP ports open to the world.
Pingback: Restart/Shutdown via remote desktop Windows « Bachem's Blog
Thanks. It helped me too.
I found I needed slashes instead of minus signs, i.e. shutdown /t 0 /r /f
There is an easier way than all of this. Create a bat file using notepad that says what Sean recommended above: shutdown -t 0 -r -f I named the bat file disconnect.bat. Then I created a shortcut to the bat file on the desktop with a cute giant X for an icon. When I click on that icon and tell it to run as administrator, the remote computer closes all programs and reboots — just as Sean said it would. Thanks for the great advice. Bob
Thanks — very helpful!
Thank you sir!!
For an interactive shutdown/restart, you only need to remember the /i option. It brings up a GUI where you can select the options (and which computers on your network to restart or shutdown)
And for those dire situations where the remote desktop will not launch anything at all, not task manager, not a command prompt, not shutdown (because of a severe out of memory bug introduced by some [censored] security software), ALT-F4 saves the day. Many thanks.
Depending on your settings when you launch MSTSC, ALT-F4 could work against the local system and just close the RDP session. By default, ALT-F4 is ‘old school’ (Win3 or older) for ‘close the current window’. Gamers throw this one out there when someone is being noobish. People still fall for it.
In MSTSC (aka RDP), click ‘show options’ then go to the ‘Local Resources’ tab. Under keyboard, notice that ‘Apply Windows key combinations:’ defaults to ‘only when using the full screen’. So, if you’re in windowed mode, ALT-F4 closes your RDP session by default.
You don’t have to add Terminal Services on Windows machines to be able to remote into them.
* You need to be on the same network or have a valid route.
* You need to have the IP address or be able to resolve the name. (Homegroup takes care of this)
* You need to have Remote Desktop enabled (in Win7, System Properties, ‘Remote’ tab, ‘Remote Desktop’ section.
Aborts the shutdown, useful if you accidentally do it on your system or if someone is playing games trying to shut your system down.
If the time value is greater than 0, -f is implied.
Gives you a GUI version that is very useful if you’re restarting a list of hosts and will let you document why.
Pingback: Note to myself: rebooting windows VM remotely through remote desktop. | pk4goodkarma
Thanks a lot ! its 5-feb-2014 and i just used it to resolve a big issue with a virtual desktop. thanks!
Sean, Thank you for the help – you made this a great computing night and help me through a tough RDP lockup – your googlieness is bountiful…. Keep up the good work, Ken
Thanks Ken. Glad to hear that I was of some assistance!
Still useful even after several years! Thanks Sean!!!
Pingback: Howto: Windows rebooten aus einer Remote Desktop Verbindung
Sean, thanks so very much for this! I bookmarked it long ago and wanted to let you know that I appreciate your blog very much. Thank you!
P.S. I agree, you are Google-worthy! :-)
Awesome! It still helps people like me, after so many years. Thanks!
Pingback: How to Reboot Machine While Connected Through Remote Desktop – Moynahan