2009
02.17


The easiest way to shutdown a Windows machine from Linux is by using Samba’s net command. The following command will send an RPC call to the Windows machine, telling it to shutdown;

net rpc SHUTDOWN -C "Comment here" -f -I xxx.xxx.xxx.xxx -U username%password

If successful, we’ll be presented with the following mesage;

Shutdown of remote machine succeeded

Change "Comment here" with whatever shutdown comment that you would like for the shutdown, and replace xxx.xxx.xxx.xxx with the IP address of the Windows machine that we are to shutdown. A valid username and password also need to be supplied as a parameter to the the -U switch.

For this command to be successful, the user we use must have shutdown privilege on the windows machine. The Windows machine also need to have RPC enabled, and no firewall is blocking port 135 as the port used by RPC. The net command itself however is only available if Samba is installed.


2 comments so far

Add Your Comment
  1. If this would work, it’d be really nice. However, when I use the command described in your post, I get the following error (twice):

    Could not connect to server 192.168.1.1
    The username or password was not correct.
    Connection failed: NT_STATUS_LOGON_FAILURE

    Things I checked:
    -triple-checked the username and password. They’re fine.
    -Windows Firewall – is turned off for debugging purpose
    -Different Windows PC – both of them respond with the same error.
    -Added the -W option providing the hostname as the domain name (I’m not running a domain). With or without -W, it doesn’t make a difference.

    Any ideas?

  2. As the message says “The username or password was not correct”

    Please use correct ID and password (you have on Windows machine)…