Sunday, 20 February 2011

Remotely Reboot Windows PC

How to remotely restart a Windows PC

I have been experiencing lots of problems with my work PC latley.

Usually these problems happen at the weekend and they turn my PC which usually performs like a bag of shit into a much larger and more non responsive bag of shit that makes any kind of work on it virtually impossible to carry out.

This means that not only does Sods Law come into effect which make me lose lots of money from my Betfair Bot not being able to place bets (why can it never fail during periods that I would have placed bad bets!). But it also means that if I manage to terminal service into the machine that it cannot connect to any other server on the network, access the internet, receive updates or send and recieve email.

I haven'nt got to the bottom of the problem yet but one thing I managed to find out today which might be useful for others to know is how to reboot a remote machine remotely from the command line.

If you can connect to the VPN that the remote PC is on and can PING the machine then you can try restarting your problematic PC. As we all know from any first line technical support a reboot is always the first port of call in any technical emergency and for Windows machines it seems to solve around 99% of all problems.

So this is the command I used from the command prompt.

shutdown -m \\pieceofshitPC -r -f

The -r flag tells it to restart rather than just shut down and the -f flag tells it to forcably shut down any running applications.

The other option is to just run

shutdown -i

from the RUN prompt and the Shutdown.exe application will open which will give you a graphical interface to manage the shut down.

This offers features such as being able to log a reason for the shutdown and specifying a time period for the system to wait before trying the reboot or restart command.

This GUI interface is just a wrapper to save those who are loath to open command prompts but if you want to use the command prompt the following flags are possible.

-i : Display GUI interface, must be the first option
-l : Log off (cannot be used with -m option)
-s : Shutdown the computer
-r : Shutdown and restart the computer
-a : Abort a system shutdown
-m \\computername : Remote computer to shutdown/restart/abort
-t xx : Set timeout for shutdown to xx seconds
-c “comment” : Shutdown comment (maximum of 127 characters)
-f : Forces running applications to close without warning
-d [u][p]:xx:yy : The reason code for the shutdown

Happy rebooting!

1 comment:

us vpn said...

Your script worked perfectly. Thank you very much for sharing them