I’ve created a windows service to start a .py script.
sc create "Maraschino" binPath= "C:\HTPC\Maraschino\maraschino-cherrypy.py" DisplayName= "Maraschino" depend= "Tcpip"
Then I’ve added a registry key to link the .py to open using python.exe
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Maraschino\Parameters]
"AppDirectory"="C:\\Python27"
"Application"="C:\\Python27\\python.exe C:\\HTPC\\Maraschino\\maraschino-cherrypy.py"
However when I try start the service I get Error 193 0xc1 which when googled revealed that it isn’t a valid exe I’m trying to start. I know its not an .exe but a .py and linking it to open with python.exe should fix this but I’m making an error. Does anyone have any insight into what I might be doing wrong when linking the script to use python.exe
Thanks
You can do this using the srvany.exe, which is a tool from Microsoft dedicated for this kind of tasks.
First, download and install the Windows Resource Kit.
Note: You only need srvany.exe, which works on all versions of Windows.
Presuming that the Windows Resource Kit was installed at C:\Program Files\Windows Resource Kits\ run:
Now, run regedit.
In the Registry Editor dialog select
HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Services > [YourService]With [YourService] selected, hit Edit > New > Key from the toolbar.
Type Parameters and hit enter.
From the toolbar select Edit > New > String Value.
Type Application and hit enter.
Right-click Application and select Modify.
Hit the OK button.
And boom! you have a nice new service.