OpenELEC Forum
shutdown remote windows machine - Printable Version

+- OpenELEC Forum (https://forum.openelec.tv)
+-- Forum: Generic Forum (https://forum.openelec.tv/forumdisplay.php?fid=5)
+--- Forum: KODI (https://forum.openelec.tv/forumdisplay.php?fid=32)
+--- Thread: shutdown remote windows machine (/showthread.php?tid=82740)



shutdown remote windows machine - pelele - 09-19-2016

Hi All,

I have this scenario.
In one room, i have my windows 7 "server", sharing all my video files.
In the living room, I have my Openelec (intel nuc) that plays everything from my server trough the lan.

When I have finshed playing a movie, i would like to shutdown the windows machine (energy saving reasons) from my remote.

I understand that i have to do these steps:
1.- Create a script to shutdown remotely my windows machine.
2.- Bind a key in my remote to execute that script.

For the script I can't use something like this:
Code:
net rpc shutdown -I IPADDRESS -U USERNAME%PASSWORD
because openelec doesn't permit to install de samba common libraries.

And for the bind i could use this:
Code:
<myKey>System.Exec("/path/to/my/script/script.sh")<myKey>
or
Code:
<myKey>RunScript(script[,args]*)</myKey>

Someone has a better idea?
Any help would be appreciated!


shutdown remote windows machine - pelele - 10-05-2016

Hi All,

In the end i could do this.

First step, i have intalled openSSH server in my windows machine, and authentication with private/public keys to no ask me password when connecting from openelec to windows.
These two guides are enough for this. Once you can connect with a simple ssh x.x.x.x command without asking password, next step.

You create a script:
/storage/.config/myscript.py (chmod +x this file)
Code:
import subprocess
import xbmcgui

dialog = xbmcgui.Dialog()

try:
subprocess.Popen('ssh root@192.168.1.11 "sh shutdown.bat"', shell=True)
dialog.notification('Remote Shutdown', 'Command sent successfully.', xbmcgui.NOTIFICATION_INFO, 5000)
except Exception:
pass

In the home on your windows machine, you must have the shutdown.bat file with your "shutdown -s -f" command, for example.

And finally, you bind the key:
Code:
<keymap>
<global>
<remote>
<yellow>RunScript('/storage/.config/myscript.py')</yellow>
</remote>
</global>
</keymap>