Jump to content
View in the app

A better way to browse. Learn more.

Universal Devices Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Has anyone written a network resource that can shutdown a Windows PC on a local network?

Featured Replies

Posted

The network resource WOL works perfectly ... but I was wondering if anyone had cobbled together an ISY network resource plus something running on a local Windows PC that could initiate a Windows shutdown?

TIA for any suggestions! Broyd.

If your PC has eventghost running on it, you can use an ISY network command to trigger a macro on eventghost and that can run a python script that executes a shutdown.  I would suggest having the PC on the same LAN as ISY to avoid any port forwarding/security concerns.  

  • Author

Thanks apostolakisl, I'll check eventghost out. Appreciate the suggestion.

  • 2 weeks later...
  • Author

Initially I was looking for a method to shutdown a Windows PC
by sending a 'something' to the PC using a network resource.

This involved setting up a task on the Windows PC that could listen
on a port and respond to a shutdown command set from the ISY.
This task would have to be loaded when the PC was booted.  

When I had a closer look at this, I realized that I also wanted
a task that would play an alarm after the PC was fully booted up.

So in the end, I set up 3 python scripts to accomplish this;
I am including them here in the event that someone else might find
them useful.

The first python script's purpose is to start the two other scripts
independently and asynchronously. That is these two scripts run
as if they were started one at a time with no dependencies
associated between either script. They run and terminate
independently of each other.


So ... here are the three python scripts


# First, RunProcesses.py

import os                                                                       
from multiprocessing import Pool
from time import sleep
                                                                                
processes = ('C:\PythonScripts\PIII-10G-ShutDown.py', 'C:\PythonScripts\Pythonplaysound.py')                                     
                                                                                
def run_process(process):
    print('\nRunning process: ' + process)
    os.system('python {}'.format(process))                                       
                                                                                
def main() :
    pool = Pool(processes=2)
    pool.map_async(run_process, processes)

if __name__ == '__main__':
    print('Starting  MAIN')
    main()
    print('Finishing MAIN')
    sleep(2)
     
---=== End of Script ===---
 
# Second, PIII-10G-ShutDown.py

# I give credit to larryllix for the core of this script; I grabbed it from the forum many moons ago.

import os
import sys
import time
import datetime
from http.server import BaseHTTPRequestHandler, HTTPServer

# HTTPRequestHandler class (HTTP requests, either from a browser or the ISY994i are handled using this class.

class myHTTPServer_RequestHandler(BaseHTTPRequestHandler):
    
    def do_GET(self):
        self.send_response_only(200)
        words = self.requestline.split()
        params = words[1].split("/",2)
        
        #debug stuff
        #print("\n\nNumber of parmameters in input string:", str(len(params)))
        #print("\nInput string passed into Python:", words)
        #print("\nParameters received: ", params)
        
        Arg1 = params[1]
        
        if Arg1 == "Shutdown" :
           print("\nShutdown received.")
           os.system('"C:\ShutDown.bat"')

        elif Arg1 == "StartXYZ" :
           print("\nStarting Program XYZ.")
           os.system('"C:\XYZ.bat"')

        else :
           print("\nUnanticipated command received: " + str(Arg1))        
 
# Server settings

def run():
    #print('\nStarting server...')
    server_address = ('192.168.1.4', 10738)
    httpd = HTTPServer(server_address, myHTTPServer_RequestHandler)
    print('\n' * 2)
    print('Running server...')
    print('\n' * 2)
    httpd.serve_forever()
    
run()    

 ---=== End of Script ===---

~~~~~~~~~
A quick note on the shutdown script above. I set up and used English words in my
Network Resource PATH item. You could use variable substitution (numbers)
instead which allow any number of functions (for the python script) to use
one Network Resource.
~~~~~~~~~   
 
# Third, Pythonplaysound.py

from time import sleep
from playsound import playsound
print('\nBig Ben initiated.')
sleep(210)

# Note:- use of the FORWARD slash in the filename for playsound

playsound('C:/PythonScripts/BigBenClockCV3.mp3')

# print('\nBig Ben completed.')

 ---=== End of Script ===---
 
 
 
And finally, the ISY network resource:

Protocol Information:

http GET   Host: 192.168.1.4   Port: 10,738  Path: /Shutdown  Timeout: 500

Guest
This topic is now closed to further replies.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.