Monday, April 15, 2013

How to : run python script as a windows service on windows 2008

Just setup one django python application, always we run the script Python manage.py start 0.0.0.0:8080 to start a web application, if you want to run this a service. here is a quick tutorial,

Download the windows resource kit which contains one utility called svcany. basically you can run cmd as a service. most command can run on windows server 2008 all though they are designed for windows server 2003. then install it.

Here is a kb about the svcany. http://www.microsoft.com/en-us/download/details.aspx?id=17657

then use the built in command SC to create one windows service. we just point the binPath to the scany.exe location.

SC Create Askbot80 binPath= “d:\windows resource kit\tools\svcany.exe”
#remember there must be a space between binpath= and the value.


Now when you go to services mmc, you can see the service is there.
image

then run regedit, to put the python script into the parameters settings.

go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\, you can see the service we just created is there already.

we just create one new key called Parameters, and under Parameters create one string key named Application , then enter the given python and python script there.
image

then you can start the service we just created.

No comments:

 
Locations of visitors to this page