Remote Shutdown of a Windows Computer from Linux

I was away for a few days with my family visiting relatives, but being self-employed it can be hard to take time off, and wouldn’t you know it I had to spend a little time online checking email, finding passwords for people and occasionally just checking in on things at the house through a remote desktop connection to my Windows computer back at home.

The only problem is that after the first night I was not able to connect to the remote desktop. I knew the machine was there, I could SSH into my Linux server and ping the Windows computer but there was no way it would properly connect a remote desktop connection. I had to reboot the Windows machine to see if I could get it back to normal. Thankfully my Linux server uses Samba as well and with a little searching I soon had my answer: http://www.linuxforums.org/forum/ redhat-fedora-linux-help/60324- remote-shutdown-windows-linux-box.html#post573872
net rpc SHUTDOWN -C “some comment here” -f -I x.x.x.x -U user_name%password

I modified it a little bit and came up with this:
net rpc shutdown -r -f -I xxx.xxx.xxx.xxx -U username

I entered my password and a few minutes later guess what I was able to do? I was able to connect to my remote desktop on my Windows machine back at home. Linux saves Windows once again.

14 thoughts on “Remote Shutdown of a Windows Computer from Linux”

  1. it tells me this :
    ~/ $: net rpc shutdown -r -f -I 192.168.2.103 -U fam-Udrescu
    Password:
    [2008/07/01 22:43:56, 0] utils/net_rpc.c:run_rpc_command(160)
    Could not initialise pipe \winreg. Error was NT_STATUS_OBJECT_NAME_NOT_FOUND

    ~/ $:

    any idea why?

  2. Sorry don’t know specifically what might be the problem, but it does look like you are giving two user names. Maybe that has something to do with it.

  3. Great. Also a very good way to safe some power during the night. In combination with wakeonlan in the morning, it will save some kw’s per year.

  4. Unfortunately I get that error, too.
    I think it might have something to do with the fact I’m using Vista Home Premium.
    I can’t use the DOS shutdown command from my XP command prompt to remotely shut down this Vista PC either. It says access is denied when using the DOS shutdown command.

    My guess is that Vista Home Premium denies all remote shutdowns.

  5. It’s alright – I found a fix for it now.
    Turns out it was just 1 simple registry addition.
    I’ll post the URL where I found the help later – I don’t have it to hand at the moment.

  6. Instead of automatic restart / shutdown XP remotely, is there anyway we ask user input?

    let’s say we ask if user click NO within 5 minutes, the shutdown will be aborted

    1. Not that I am aware of. A quick check on my machine shows the following options for net rpc

      Usage:
      net rpc audit Modify global audit settings
      net rpc info Show basic info about a domain
      net rpc join Join a domain
      net rpc oldjoin Join a domain created in server manager
      net rpc testjoin Test that a join is valid
      net rpc user List/modify users
      net rpc password Change a user password
      net rpc group List/modify groups
      net rpc share List/modify shares
      net rpc file List open files
      net rpc printer List/modify printers
      net rpc changetrustpw Change trust account password
      net rpc trustdom Modify domain trusts
      net rpc abortshutdown Abort a remote shutdown
      net rpc shutdown Shutdown a remote server
      net rpc samdump Dump SAM data of remote NT PDC
      net rpc vampire Sync a remote NT PDC’s data into local passdb
      net rpc getsid Fetch the domain sid into local secrets.tdb
      net rpc rights Manage privileges assigned to SID
      net rpc service Start/stop/query remote services
      net rpc registry Manage registry hives
      net rpc shell Open interactive shell on remote server

      There is the option to abort a shutdown, but nothing to ask for user input.

Leave a Reply

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