Reboot from remote desktop


Remote Desktop (mstsc.exe) is great: it allows me to access another remote machine as if I were sitting at its keyboard and seeing its screen.

 

My web server sits on top of a 7 foot tall bookcase but I have no need to touch it: I can use RD from other machines anywhere in the world.

 

It’s not obvious how to reboot the remote machine. The WinXP start menu Shut down option says “Disconnect” rather than “Shut down” and Ctrl-Alt-Del is intercepted by the local machine. (Windows Server 2003 has Disconnect as an option on the Shutdown menu.)

 

Here’s a simple way from within VFP (or similarly from VBScript or Jscript):

 

x=CREATEOBJECT(“shell.application”)

x.ShutdownWindows()

 

 

This brings up the Shutdown Windows dialog from which one can choose to Restart, Stand By, Shut Down, etc.

 

You can start RD simply from the VFP command window:

 

!/n mstsc

 

Or from the WinXP start menu:

 

Windows_Key+R mstsc

 

Comments (64)

  1. Jakeypoo says:

    How about Ctrl+Alt+End?

  2. Wayne Kao says:

    Or, when you’re connected to the remote machine, from the command-line ("cmd"), just do:

    – "shutdown" to shutdown

    – "shutdown -r" to reboot

    – "shutdown -i" to get a GUI

    – "shutdown -l" to logoff

  3. Scott Glasgow says:

    Actually, to run shutdown from RD, you have to use the -f (force) switch to actually get the machine to shutdown or reboot.

    Something like….

    shutdown -r -f

  4. Nicole Calinoiu says:

    Or how about using the "Windows Security" item on the start menu?

  5. Scott Glasgow says:

    Hmm, ok, I guess you can just do a shutdown -r.

    I know I tried once before and it said I had to use the force option.

  6. ShadowChaser says:

    I always thought you could use the Windows Security option to bring up the Ctrl-Alt-Delete menu and select shutdown from there.

  7. Ben says:

    Control-Alt-Delete.

    In the task manager you can use the "Shut down" menu to either reboot or powerdown.

  8. Raj Kaimal says:

    if you don’t like the Windows Security option, how about iisreset /reboot?

  9. dean says:

    thank you very much. I found this post via google. Was very after remotly flashing my dvd firmware!

  10. /usr/bin/Paul says:

    I don’t know what your all fussing about, the suggestion from Jakeypoo works perfectly. Just press Ctrl+Alt+End and it does the same as pressing Ctrl+Alt+Del on a normal system.

  11. who? says:

    Ctrl + Alt + End worked! I’m saved!

  12. mattchoo says:

    ctrl-alt-end works great…but It’s nice to know the alternatives. I was recently remote desktop’d into another remote desktop and ctrl-alt-end would bring up the first remote desktop windows security screen. shutdown -r was the obvious answer and i didn’t think of it till reading here. thanks!

  13. darkennis says:

    on some systems (using RD) I have the option to shutdown from the windows Start button. does anyone know why this is not consistent?

  14. Joe H says:

    I was once able to reboot my XP file-share machine from the start menu, but have noticed that I lost that functionality. I presume this was in one of the Microsoft updates…

  15. Matt says:

    I would suggest using PSTools. It is freeware that can be found all over the net. You can remotely shutdown/restart machines, see how long a machine has been up and what hardware it has, list installed software, list running processes and kill them, and my favorite has been using a psexec \hostname cmd , which get you into dos command line on the remote pc.

  16. pgn says:

    On WinXP, the "taskkill" command has been helpful when I’ve needed to shutdown an RD that’s been 2 or 3 hops away from me (ie daisy-chained RD sessions) or a misbehaving RD session:

    From a CMD window (or create a .bat file with the following in it) type the following, then wait a couple of minutes for the machine to go down and come back up again.

    taskkill /f /im lsass.exe

  17. dev says:

    how to reboot a RD when its hang.

  18. AB says:

    Sweet! My machine at work was showing nothing but a black screen over RD … Ctrl + Alt + End popped the task mgr, which forced a repaint or whatever, and I was back in business, skipping the 30 minute drive to and from the office to reboot!

  19. Briggsy says:

    This may be a stupid question, hopefully it is an easy answer. But i connect from a work PC to my home PC where remote desktop is setup. If i need to reboot the home PC for any reason, i used "windows security tab" worked fine and my home PC physically shutdown. When the PC restarts i cannot remote desktop connect onto it again because it is at the log in screen, and i don’t think it has loaded the files needed to host a remote connection. I cannot remote connect untill i physically log in on that PC.

  20. Calvin_Hsia says:

    Briggsy: when a Windows XP machine is rebooted and nobody has logged in yet, a user can still remote desktop to the machine. I do this many times. One of my remote machines (web server) is on top of a 7 foot tall bookcase and I hardly touch it. When it gets reboot due to security updates, I can still RD to it with no problem.

  21. BenLG says:

    Briggsy, I just called my girl friend to tel to log in because I had to reboot the machine and SP2 of XP does not load the netwoork interface until the user as logged in

    does anyone know the work arround ? Im running XP MCE…

  22. click start click run type "control userpasswords2" from here you can select a user to auto log into the box on boot up.

  23. Harry Spooner says:

    Found this via google as well.

    shutdown -r

    worked great!  Thanks for the great info.

  24. For some reason, one of my machines running Windows XP seemed to die while I was away at a meeting. I…

  25. Martin Duncan says:

    Another googler :-)!

    shutdown -i -l -r did the trick for me.  A very useful post.

  26. Krede says:

    Anyone who knows how to force win 2003 server to load network drivers after rebooting?

    Preferrably without having to make an automated user login?

  27. It takes a lot of work to create the blog posts and code samples that I put in my blog, and I was curious…

  28. Coupland says:

    shutdown -r works just fine without the -f switch

    but I always use shutdown -r -t 0 because I don’t like waiting for the 30 second countdown

    another potentially useful command is CTRL+ALT+END… this will launch the Task Manager

  29. Ajith says:

    Pressing Ctrl+Alt+End will not work when your TS session is deeper than one level. In such cases, invoke the On Screen Keyboard (Start > Run > osk) on the nearest TS session and click "Ctrl+Alt+End" keys using you mouse. It worked.

  30. peter B. says:

    Does anyone know why a remote PC running Windows XP sp2 will reboot (or maybe it just logs itself off) after every session? even though I do a start, run, disconnect? every time I do that and try to access the PC again I have to log back into my AD account.

  31. ASHISH says:

    Simple alt – f4 after closing all active windows

  32. Yuval Ararat says:

    You can connect to the console session on the server and then you will get the Start->Shutdown item instead of the disconnect.

    use this in the command line:

    mstsc /v:[your server] /console

    this will save you tons of scripting.

  33. Corey Goode says:

    Yup…

    Even connecting through Cisco VPN to my work network, RDP’ed into my desktop I can reboot using the "CTL-ALT-END" keys as stated by the tech above… easy sleazy way to reboot that sucker!

    Corey

  34. Daan says:

    Another googler here! This page has saved me a 1.5hour round trip to the office. Thanks!

    Daan

  35. yoyo says:

    Ctrl+Alt+End works, BUT:

    Why not just R-click on the TaskBar and select Task Manager?

    This should probably also work for multiple levels of RD…

  36. Brian says:

    Ctrl-Alt-Delete will reboot the machine that you’re sitting in front of.  Not what I wanted.

    Ctrl-Alt-End works to reboot a machine that you are connected to remotely.  Thanks guys!

  37. Rodge says:

    Hey guys, I had a server that I had rebooted but after logging in, it was hung on a blue background, no icons, no taskbar and shutdown, windowskey + r, ctrl alt end all would not work, but I was able to rdp to another dc in the same lan and taskkill to stop lsass which rebooted the server, thanks!

  38. Ken says:

    I want to shutdown my PC.

    I use my home PC to check my e-mails but when I’m going home I want to shut it down. The problem is that the pc restarts don’t know why…

    I tried "shutdown", "shutdown f", "Ctr + Alt + End", "Start -> Windows Security" and nothing…

    Always it restart.

    I’m using Windows XP MCE Sp2.

    Any idea?

    Thanks

  39. Shan says:

    On the remote machine click Start -> Settings -> Windows Security

  40. JM says:

    I think if you do the Windows update for Remote Desktop it will add the shutdown option.

  41. All hung says:

    Does anyone how to force restart on a 2003 server that does not respond to shutdown -f -r -m\ servername or any other attempt to restart remotely? Or is hard switching the power all that´s left?

    Thanks

  42. Matt says:

    Yea, Ctrl-Alt-End does it for the remote machine.

  43. I found it incredibly funny that the first few options involve mini-scripts and command line options. Then, out of nowhere, we get "Or how about using the "Windows Security" item on the start menu?"

    Classic.

  44. Anty says:

    shutdown -r worked perfectly, but I need to wait for 30 sec, which is negligible.

  45. Bob says:

    use -t 00 in the command line…

  46. Ancient says:

    To access a computer after a  restart, Windows service "Terminal Services" must be set to automatic startup.

    This solves the issue neatly :)

  47. Googler says:

    Another Googler saved a 2 hr round trip to the office on the weekend.

    Thanks

  48. Me says:

    Google and Calvin Hsia saved me too!

  49. Abu says:

    can add much more except Thanks.

    Shut down re-started machines in Aberdeen and Bangkok.

    Ta.

  50. Scott W. says:

    Thanks for the great ideas!  On a similar note, is there a way to get an XP machine to reboot at a set time (ie, daily in the middle of the night?)

  51. Lloyd says:

    Scott W – I used to do this. I used to get my machine to shutdown each night at 1am. You can create a bat file that has shutdown commands in it and then set up a scheduled task to hit that bat file at whatever time/date you want.

  52. pgriffin says:

    I hope someone help with my RDP dilemma. When I reboot a windows 2003 SP2 server via remote desktop connection, sometimes I can’t RDP after the server comes back up.  I physically have to go to the server rack, login to the server and restart it before I can make any RDP connection.  This has caused great pains when I reboot servers from my home. This is not just one server. All twenty servers do this sometimes. Some servers are in Admin TS mode and others are in application TS mode.

  53. scott says:

    thanks for posting this, it helped me.

  54. webber says:

    Very useful. I had no idea there were soooo many ways to shutdown

  55. shane says:

    pgriffin: use [server] /console to correct that problem.

  56. John Hughes says:

    Do any of you know how to do a remote shutdown of a Windows XP machine from a Linux machine.  I don’t want to do a remote login (remote desktop) into the XP machine.  I just want to be able to shut it down.  I would like to be able to do it from a script running on the Linux box, or I can write a piece of c code to run on the Linux box.  I have been looking for a way to do this for many days now.

  57. src says:

    Similar to pgriffin’s problem, after I reboot my remote XP SP3 machine, it won’t let me RDP in as it seems the network drivers aren’t loaded yet.  "Terminal Services" is set to automatic startup.

    I have to physically login to the machine before it will allow me to RDP.

    Is there a way to force the drivers to load on bootup so I can RDP in after a reboot?

  58. Sal says:

    Shutdown -r,

    All that crap people post and thats all you need. Shutdown ? will show you that!

  59. Steve says:

    LOL. Hilarious… Saved me tons of time this one

  60. Chris says:

    a 5-year-old thread that deserved to be the top hit for my search!

  61. Mattias says:

    I use alt+F4 to reboot the machine