Perl script into a Windows Service

C

Cosmic Cruizer

For the last several months, I have been trying to turn a simple Perl script
into a Windows 2000 service. I keep finding a lot of question about doing
this in newsgroups, but I have yet to find an easy to follow solution. Can
anybody recommend either a book, web page, article, or something that will
help me out? It almost sounds like setting up a Perl script to run as a
service is an urban legend.

Thanks,
 
C

Chris

Cosmic said:
For the last several months, I have been trying to turn a simple Perl script
into a Windows 2000 service. I keep finding a lot of question about doing
this in newsgroups, but I have yet to find an easy to follow solution. Can
anybody recommend either a book, web page, article, or something that will
help me out? It almost sounds like setting up a Perl script to run as a
service is an urban legend.

No, it's not an urban legend. It's actually not that hard to do.
Recent versions of Perl make this rather easy to do. I know this sounds
weird, but I don't have access to the Web right now to find what I know
is out there, but do some searching on Dave Roth -- he's king of Perl
Win32 and I know I saw some outlines from him within the last two years
on the preferred way to create WinNT-based services using ActiveState Perl.

The poor man's method, which works best for older versions of
ActiveState Perl (esp. 5.00x) is to use Microsloth's SRVANY.EXE
executable. Look in Microsloth's (pathetic) Support/KB engine for
SRVANY.EXE and see what you come up with. There is a KB article that
explains the registry pokes/insertions that need to be done to setup
your own service using a script and SRVANY.EXE.

Writing an installer to install an app using either method is not hard
to do either.

I can be more specific about the SRVANY.EXE method if you need more
guidance. Hope this gets you going.

Chris
 
C

Cosmic Cruizer


Thanks Andy and Chris.

The link listed above is pretty easy to follow. I will need to give it a try
when I have a bit more time.

Since I finally needed to get something up and running for the weekend, I
kind of cheated. I'm trying out Firedaemon. It took me all of 10 minutes to
get my service up and running. But the real test will be on Monday when I
check out the server.

Thanks for the suggestions.
 
K

Kevin Sproule

Cosmic Cruizer said:
For the last several months, I have been trying to turn a simple Perl script
into a Windows 2000 service. I keep finding a lot of question about doing
this in newsgroups, but I have yet to find an easy to follow solution. Can
anybody recommend either a book, web page, article, or something that will
help me out? It almost sounds like setting up a Perl script to run as a
service is an urban legend.

Thanks,

Here are some generalized instructions that I use all the time to setup Perl
scripts as services under Windows NT 4.0, 2000, XP, and 2003:

Copy the INSTSRV.EXE and SRVANY.EXE files to C:\WINNT\SYSTEM32.

Run: INSTSRV Service_Name C:\WINNT\SYSTEM32\SRVANY.EXE
(This registers the service.) Service_name

Set the "Logon As" to Local System Account in the service properties.

Run: REGEDIT
Follow the chain:
HKEY_LOCAL_MACHINE
SYSTEM
CurrentControlSet
Services
Service_Name

Add the KEY: Parameters
Select (highlight) Parameters
Add the String Value: Application
String: C:\PERL\bin\perl.exe ( your path to the perl.exe program )
Add the String Value: AppParameters
String: C:\some_dir\perl_script.pl ( your path to the perl script to be
run )
Exit the Registry Editor.
Start the Service_Name service.

In the event that you want to remove the Service_Name service, stop the
service and run:
INSTSRV Service_Name REMOVE

I hope this helps.

Kevin Sproule
 
C

Cosmic Cruizer

Here are some generalized instructions that I use all the time to setup
Perl scripts as services under Windows NT 4.0, 2000, XP, and 2003:

Copy the INSTSRV.EXE and SRVANY.EXE files to C:\WINNT\SYSTEM32.

Run: INSTSRV Service_Name C:\WINNT\SYSTEM32\SRVANY.EXE
(This registers the service.) Service_name

Set the "Logon As" to Local System Account in the service properties.

Run: REGEDIT
Follow the chain:
HKEY_LOCAL_MACHINE
SYSTEM
CurrentControlSet
Services
Service_Name

Add the KEY: Parameters
Select (highlight) Parameters
Add the String Value: Application
String: C:\PERL\bin\perl.exe ( your path to the perl.exe program
)
Add the String Value: AppParameters
String: C:\some_dir\perl_script.pl ( your path to the perl script
to be
run )
Exit the Registry Editor.
Start the Service_Name service.

In the event that you want to remove the Service_Name service, stop the
service and run:
INSTSRV Service_Name REMOVE

I hope this helps.

Kevin Sproule

WOW... Talk about easy. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top