[SOLVED] Script to remotely reboot from a Windows 10 PC

  • Is there any way to make some kind of script that would reboot my RPi that could be executed from a Windows 10 computer?

    Right now I'm doing it manually using Putty but would be great if there was a way to automate it.

    Richard Åsberg

  • Thanks for your input guys!

    After some trial and error I found using a batch file as seen below works really good.

    start "" d:\util\putty [email protected] -pw libreelec -m "D:\Util\Reboot Photo Frame.txt" > NUL

    timeout /T 3 > NUL

    taskkill /IM putty.exe /f > NUL

    Reboot Photo Frame.txt above contains the single command reboot.

    My goal with all this is to automatically refresh the slideshow whenever new photos have been added/deleted. I'm using a software called GoodSync to make sure whenever I change anything to the contents in the local folder (on my Windows 10 PC) where I keep the photos I want to show, the same changes are carried out on the external USB drive connected to my RPi running LibreELEC. Then there's an option in GoodSync to execute a command or an application once the job has finished. This is where I execute my batch file seen above that will restart my RPi and Kodi.

    I'm also making use of autoexec.py with the below commands to have the slideshow start automatically after a reboot.

    import xbmc


    The only two things right now that don't work perfectly are:

    1. Sometimes it seems autoexec.py isn't executed during Kodi startup because I end up in the main menu rather than having the slideshow start

    2. GoodSync gets a bit upset when it's temporarily loosing the network connection to the external USB drive connected to my RPi at the time it reboots

    For nr 1 I don't have a clue what is causing it. I would say it's working about 4 out of 5 times so almost seems like some kind of timing issue.

    For nr 2 I guess what would be an even better solution is if there was a way to restart Kodi rather than rebooting the RPi. That way the network connection would never be lost and still the slideshow would be refreshed with any new or deleted photos since restarting Kodi is enough to refresh the slideshow. I guess rebooting the RPi is a bit of overkill.

    Will give it a go and see if I can find a way to replace the reboot command in my batch file with a simple restart of Kodi instead. With close to zero knowledge of Linux it's lots of trial and error and searching on Google but that's part of the fun :)

    Any further input or tips on both 1 and 2 above would be highly appreciated!

    Richard Åsberg

  • Don't I just love Google :thumbup:

    All that was needed was to replace the command reboot in Reboot Photo Frame.txt with systemctl restart kodi

    Fact is this seems to have fixed issue nr 1 as well (fingers crossed) because I've tried restarting Kodi lots of times and still it hasn't failed once to automatically start the slideshow.

    Sorry for the wall of text in the last couple of posts but since I've invested quite an amount of time into having this kind of solution I figured I would share all the details with anyone else looking for the same kind of setup to have a fully automatic photo frame based on a RPi with LibreELEC where you're able to manage everything directly from your Windows 10 PC simply by adding/deleting photos to a folder of your own choice.

    Maybe someone wonders why I simply don't just add/remove photos directly to/from the external USB drive attached to my RPi. Reason for this is I like to use the same photos for a screensaver slideshow on my Windows 10 PC and it's very nice when you only have to think of one folder where the rest of the process will be automatic.

    Well, time to sit back and relax for a bit and just enjoy what I've accomplished ^^

    Thanks again for pushing me in the right direction!

    Richard Åsberg

  • ...and a couple of final touches...;)

    Creating a vbs script that calls the batch file. Adding /MIN to the start command like this start "" /MIN d:\util\putty [email protected] -pw libreelec -m "D:\Util\Restart Photo Frame.txt"

    Both these in order to show as little as possible on the screen when the commands are executed. The content in the vbs script looks like this in my case.

    Set WshShell = CreateObject("WScript.Shell" )

    WshShell.Run chr(34) & "D:\Util\Restart Photo Frame.cmd" & Chr(34), 0

    Set WshShell = Nothing

    As you can see I also renamed both the batch file and text file to Restart Photo Frame.cmd and Restart Photo Frame.txt since I no longer reboot but rather restart Kodi.

    Mission accomplished...at least for the time being ;)

    Richard Åsberg

  • Klojum

    Changed the title of the thread from “Script to remotely reboot from a Windows 10 PC” to “[SOLVED] Script to remotely reboot from a Windows 10 PC”.