Shutdown a Windows machine from the UNIX command line

Picked up this nifty trick from command-line-fu

$ net rpc shutdown -I ipAddressOfWindowsPC -U username%password

This will issue a shutdown command to the Windows machine. username must be an administrator on the Windows machine. Requires samba-common package installed. Other relevant commands are:

net rpc shutdown -r : reboot the Windows machine

net rpc abortshutdown : abort shutdown of the Windows machine

Type:

net rpc

to show all relevant commands

The “net rpc service” command looks spiffy.

Michael-Svobodas-MacBook-Pro:~
(michael)> net rpc

Usage:
net rpc info             show basic info about a domain
net rpc join             to join a domain
net rpc oldjoin             to join a domain created in server manager
net rpc testjoin         tests that a join is valid
net rpc user             to add, delete and list users
net rpc password <username> [<password>] -Uadmin_username%admin_pass
net rpc group         to list groups
net rpc share         to add, delete, list and migrate shares
net rpc printer         to list and migrate printers
net rpc file             to list open files
net rpc changetrustpw     to change the trust account password
net rpc getsid         fetch the domain sid into the local secrets.tdb
net rpc vampire         syncronise an NT PDC’s users and groups into the local passdb
net rpc samdump         diplay an NT PDC’s users, groups and other data
net rpc trustdom         to create trusting domain’s account or establish trust
net rpc abortshutdown     to abort the shutdown of a remote server
net rpc shutdown         to shutdown a remote server
net rpc rights        to manage privileges assigned to SIDs
net rpc registry        to manage registry hives
net rpc service        to start, stop and query services
net rpc audit            to modify global auditing settings
net rpc shell            to open an interactive shell for remote server/account management

‘net rpc shutdown’ also accepts the following miscellaneous options:
-r or –reboot    request remote server reboot on shutdown
-f or –force    request the remote server force its shutdown
-t or –timeout=<timeout>    number of seconds before shutdown
-C or –comment=<message>    text message to display on impending shutdown

5 thoughts on “Shutdown a Windows machine from the UNIX command line”

  1. I get the following error. I am using MacBook however not sure what a samba package is. When I run the cmc here is what I get:

    Could not connect to server 192.168.0.6
    Connection failed: NT_STATUS_CONNECTION_REFUSED
    Could not connect to server 192.168.0.6
    Connection failed: NT_STATUS_CONNECTION_REFUSED

  2. this is great!
    but the administrator and password are in the command line. how does it be send to windows server?

    if it’s not encrypted. it’s not safe!
    could you figure out a more safe way?

  3. @rewing: If you have someone snooping passwords inside your LAN, you already have big problems, so perhaps you should not use File and Print Sharing or Client for Microsoft Networks or Samba.

Leave a Reply

Your email address will not be published. Required fields are marked *