How to install a Perl script as a service in Windows Filed Under: Perl
Introduction
Well, this is a quick tutorial on how to install a Perl script in windows. Although this tutorial is based around a Perl script you can install any other application as a service using the same steps. The only requirements are that you need to have the instsrv.exe and srvany.exe applications from Microsoft but do not worry as they are free and you can download them from the Microsoft website.
Install the script as a service
To install the script as a service execute the following command.
instsrv SERVICE_NAME "pathtosrvany"\srvany.exe
So for example:
instsrv TestSrv "C:\Program Files\Windows Resource Kits\Tools\srvany.exe"
Edit the parameters of the service
After we have installed the service we will add parameters to the service so it can execute our script as a service.
First open the registry and go to the following key.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SERVICE_NAME
Where “SERVICE_NAME” is the name of your service.
Then create a new key called “Parameters” (don’t put the double quotes :-))
Inside that key you need to create two new string values
- Application
- AppParameters
in Application write the path to the Perl binary e.g. c:\perl\bin\perl.exe.
in AppParameters put the path to the Perl script to be executed. Note that if the path contains spaces then you need to put the path between double qoutes.
Additional notes on registry values
With the above, we have a working service that you can start but if you want to modify some values like the display name and description, add the following string values under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SERVICE_NAME
- DisplayName – name to display in the services menu
- Description – description of the service
After all this is done you can start the service.
Remove the service
If for any reason you wanted to remove the service execute the following command:
instsrv SERVICE_NAME REMOVE
For example: instsrv TestSrv REMOVE
Tags: install, Perl, service, windows
- Permalink
- Alberto Diaz
- 26 Jul 2008 9:50 AM
- Comments (0)