python script under windows

Grig Gheorghiu grig.gheorghiu at gmail.com
Fri Sep 9 11:32:11 EDT 2005


Jan,

Here's what I did to run a Python script (let's call it myscript.py) as
a service:

1. Install Win2K Resource Kit.

2. Run instsrv to install srvany.exe as a service with the name
myscript:

C:\Program Files\Resource Kit\instsrv myscript "C:\Program
Files\Resource Kit\srvany.exe"

3. Go to Computer Management->Services and make sure myscript is listed
as a service. Also make sure the Startup Type is Automatic.

4. Create a myscript.bat file with the following contents in e.g.
C:\pyscripts:

C:\Python23\python C:\pyscripts\myscript.py

5. Create new registry entries for the new service.
- run regedt32 and go to the
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\myscript entry
- add new key (Edit->Add Key) called Parameters
- add new entry for Parameters key (Edit->Add Value) to set the
Application name => Name should be Application, Type should be
REG_SZ, Value should be path to myscript.bat, i.e.
C:\pyscripts\myscript.bat
- add new entry for Parameters key (Edit->Add Value) to set the working
directory => Name should be AppDir, Type should be
REG_SZ, Value should be path to pyscripts directory, i.e. C:\pyscripts

6. Test starting and stopping the myscript service in Computer
Management->Services.




More information about the Python-list mailing list