Shut down remote Windows computer

Posted on
Wed Dec 17, 2014 8:53 am
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Shut down remote Windows computer

Hi!

I'm new to Indigo/Python/Applescripts, just converted from HomeSeer. In HS I could shut down a remote windows-computers by running "shutdown.exe -s -f -t 0 -m \\<computer name>" on the lokal HS-computer (Windows).

I have installed Samba on the Indigo computer and can run "net rpc shutdown -I 192.168.123.13 -U <PC-USER>%<PC-PSW>" in Terminal to shut down the remote computer but how do I use this in a script?

Or is there another way to use scripting (or plugin) to do this from Indigo?

Best regards, L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Wed Dec 17, 2014 10:37 am
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Shut down remote Windows computer

The following AppleScript should work:

Code: Select all
tell application "Finder" of machine "eppc://192.168.123.13"
   using terms from application "Finder"
      shut down
   end using terms from
end tell


You'll want to run it once manually - it'll prompt you for authentication from the other Mac but it can save that to the Keychain which (I think) will avoid the dialog in subsequent runs.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Dec 17, 2014 2:09 pm
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: Shut down remote Windows computer

Thanks, but the other computer is still a windows machine :(

L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Wed Dec 17, 2014 2:22 pm
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Shut down remote Windows computer

OH - sorry, guess I didn't read closely enough.

You can execute that shell command thusly in AppleScript:

Code: Select all
do shell script "net rpc shutdown -I 192.168.123.13 -U <PC-USER>%<PC-PSW>"

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Dec 18, 2014 1:32 am
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: Shut down remote Windows computer

Nothing happens :( What could be wrong? "net rpc shutdown -I 192.168.123.13 -U <PC-USER>%<PC-PSW>" works from Terminal but w/ do shell script "net rpc shutdown -I 192.168.123.13 -U <PC-USER>%<PC-PSW>" in an embedded applescript nothing happens.

EDIT: I get this when I run it:
"sh: net: command not found"

/L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Thu Dec 18, 2014 8:17 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Shut down remote Windows computer

Use the full (absolute) path to the net executable. I'm not sure what that is, but "which net" from the Terminal will probably show it for you.

Image

Posted on
Thu Dec 18, 2014 9:13 am
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: Shut down remote Windows computer

Works!!
Love the support! Migrating from HomeSeer looks like a no brainer w/ the help from the forum.

//L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Thu Dec 18, 2014 2:22 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Shut down remote Windows computer

I'll be looking at adding this to my control pages - I have WOL for my PC, but shutdown for my windows server (which is essentially headless) would be cool.

Posted on
Fri Dec 19, 2014 3:31 am
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: Shut down remote Windows computer

Works great, but you will have to install Samba (OSx version of Samba does not work).

Configure PC
Install Homebrew on Mac (don't forget "brew doctor" in the end)
Install Samba on Mac (Terminal): "brew install samba"

//L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests

cron