Sean’s Stuff

17 January, 2009

How to Reboot Machine While Connected Through Remote Desktop

Filed under: Windows — Sean @ 4:24 pm
Tags: ,

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!

About these ads


  1. Good to know. thxs!

    Comment by reno — 17 January, 2009 @ 7:32 pm | Reply

  2. Great worked awesome!!!!!!

    Comment by Mike G — 23 March, 2009 @ 2:14 pm | Reply

  3. Pressing Alt-F4 in remote session will bring up the menu you need to shutdown or reboot.

    Comment by Mark — 28 July, 2009 @ 4:12 pm | Reply

  4. I think that Alt-F4 just closes the active application, no? (At least it does for me, remoted into a Win XP machine).

    Comment by Sean — 28 July, 2009 @ 5:32 pm | Reply

  5. 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!

    Comment by Sean — 28 July, 2009 @ 5:34 pm | Reply

  6. you can also press CTRL-ALT-END which sends a CTRL-ALT-DEL though RDC to the host

    Comment by Adam — 15 September, 2009 @ 6:14 pm | Reply

    • ctrl-alt-end does not give shutdown options in windows 7.

      Comment by Tim — 14 January, 2010 @ 8:38 pm | Reply

      • 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.

        Comment by Sean — 14 January, 2010 @ 9:15 pm

    • 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

      Comment by Charles — 13 May, 2014 @ 3:37 pm | Reply

  7. 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)”

    Comment by Lou — 21 December, 2009 @ 2:02 am | Reply

  8. 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.

    Comment by Greg — 21 February, 2010 @ 10:29 pm | Reply

  9. how i recover hard drive bad secteor.

    Comment by kamal paria — 23 February, 2010 @ 10:12 am | Reply

  10. It helped :)

    thanks a lot!

    Comment by alexanderb — 2 September, 2010 @ 10:34 am | Reply

  11. That works great!!

    Comment by Ashu — 20 April, 2011 @ 6:33 pm | Reply

  12. 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.

    Comment by Mike — 23 June, 2011 @ 2:15 pm | Reply

    • 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.

      Comment by Scott — 11 May, 2013 @ 6:53 pm | Reply

  13. Thanks. It helped me too.

    Comment by Pavel Tsukanov — 28 June, 2012 @ 8:46 pm | Reply

  14. I found I needed slashes instead of minus signs, i.e. shutdown /t 0 /r /f

    Comment by Mark F — 6 October, 2012 @ 10:36 am | Reply

  15. 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

    Comment by Bob — 17 October, 2012 @ 4:23 pm | Reply

  16. Thanks — very helpful!

    Comment by Christine S. — 12 February, 2013 @ 10:45 pm | Reply

  17. Thank you sir!!

    Comment by — 13 February, 2013 @ 6:40 am | Reply

  18. 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)

    Comment by R Duke — 14 February, 2013 @ 9:04 pm | Reply

  19. 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.

    Comment by joe — 14 March, 2013 @ 1:00 am | Reply

    • 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.

      Comment by Scott — 11 May, 2013 @ 6:48 pm | Reply

  20. 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.

    shutdown -a
    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.

    shutdown /i
    Gives you a GUI version that is very useful if you’re restarting a list of hosts and will let you document why.

    Comment by Scott — 11 May, 2013 @ 6:43 pm | Reply

  21. […] who may have faced this problem may have noticed you get disconnect option but not restart. So this awesome blog helped me […]

    Pingback by Note to myself: rebooting windows VM remotely through remote desktop. | pk4goodkarma — 15 September, 2013 @ 6:42 am | Reply

  22. Thanks a lot ! its 5-feb-2014 and i just used it to resolve a big issue with a virtual desktop. thanks!

    Comment by Lorenzo — 5 February, 2014 @ 10:08 pm | Reply

  23. thanks

    Comment by kiprono — 24 March, 2014 @ 10:01 am | Reply

  24. 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

    Comment by Ken — 27 March, 2014 @ 2:55 am | Reply

    • Thanks Ken. Glad to hear that I was of some assistance!

      Comment by Sean — 27 March, 2014 @ 12:00 pm | Reply

  25. Still useful even after several years! Thanks Sean!!!

    Comment by David Segal — 19 April, 2014 @ 10:48 pm | Reply

  26. 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! :-)

    Comment by Wolfe Scott — 6 June, 2014 @ 6:14 pm | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Rubric Theme. Blog at


Get every new post delivered to your Inbox.

Join 490 other followers

%d bloggers like this: