Restarting a Remote Machine not on the Current Domain

Recently I needed to restart a remote test host machine. If you want to restart a remote machine which is on the same domain as the local machine you are going to use to issue the restart command, then you can use the normal shutdown.exe command line utility:
C:\localmachine> shutdown.exe /r /m \\remotemachinename
Or, if the remote machine you want to restart has Remote Desktop enabled, then you can remote in using the mstsc.exe utility (Start -> Run -> mstsc -> <enter>) and then either simply click Start -> Shut Down -> Restart if that option is available, or do a <CTRL>-<ALT>-<END> to get a restart dialog box. But what if the remote machine is neither on the same domain as your local machine, nor accessible via Remote Desktop? One way to restart such a remote machine is to use the net use command to connect to the remote machine, and then use shutdown. For example, suppose you want to restart some machine which has IP address from your local machine. The scenario could resemble:
C:\localmachine> ping
Reply from bytes=32 time=32ms TTL=116
Reply from bytes=32 time=32ms TTL=116
C:\localmachine> net use \\\c$
Enter the user name for ‘’: administrator
Enter the password for ********
The command completed successfully
C:\localmachine> shutdown.exe /r /m \\
And the remote machine will restart after the default delay of 30 seconds. Finally you can clean up with:
C:\localmachine> net use \\\c$ /delete
\\\c$ was deleted successfully.
C:\localmachine> _
There you have it. Like many things, easy and obvious once you know how to do it, but not so easy or obvious if you don’t know how.
This entry was posted in Software Test Automation. Bookmark the permalink.