<?xml version="1.0" encoding="windows-1252"?>
<node id="911431" title="Re: Install a perl script as a Win NT/2000/XP service." created="2011-06-25 23:52:08" updated="2011-06-25 23:52:08">
<type id="11">
note</type>
<author id="824928">
marmanold</author>
<data>
<field name="doctext">
&lt;p&gt;None of the above worked for me on Windows 7 64-bit, but they did lead me in the right direction.  &lt;a href="http://iain.cx/src/nssm/"&gt;The Non-Sucking Service Manager&lt;/a&gt; ended up being the key.  Below is the code for the two .bat scripts needed to install a Perl script as a service in Windows 7 64-bit.  It should also work in 32-bit versions, but I have not been able to test this yet.&lt;/p&gt;
&lt;p&gt;
install_service.bat&lt;br/&gt;
&lt;code&gt;
@echo off
if defined %ProgramFiles(x86)% (
	"%ProgramFiles(x86)%\path_to\your_app\service\nssm.exe" install myService "C:\Program Files (x86)\path_to\your_app\portable_perl\perl\bin\perl.exe" """C:\Program Files (x86)\path_to\your_app\myService.pl"""
) else (
	"%ProgramFiles%\path_to\your_app\service\nssm.exe" install myService "C:\Program Files\path_to\your_app\portable_perl\perl\bin\perl.exe" """C:\Program Files\path_to\your_app\myService.pl"""
)
net start myService
exit

&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
remove_service.bat&lt;br/&gt;
&lt;code&gt;
@echo off
net stop myService
if defined %ProgramFiles(x86)% (
	"%ProgramFiles(x86)%\path_to\your_app\service\nssm.exe" remove myService confirm
) else (
	"%ProgramFiles%\path_to\your_app\service\nssm.exe" remove myService confirm
)
exit

&lt;/code&gt;
&lt;/p&gt;</field>
<field name="root_node">
230377</field>
<field name="parent_node">
230377</field>
</data>
</node>
