Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Perl file (.pl) file with arguments as windows service

01 Jan 2013   #1

Windows 7 64 Bit
Perl file (.pl) file with arguments as windows service

I am running Windows 7 32-bit. I have a perl script which i want to start everytime computer starts. Setting it as service will be a good option as i can start and restart the service from command line.

In windows XP I was using srvany.exe but that is not a good solution. Is there any way I can make this Perl Script which takes in some command line arguments as windows service. Tried using sc.exe, with that service is created but it fails to start.

To run that perl script i run on command line:
perl --arg1 Hello --arg2 Buddy --arg3 Good

Any help will be highly appreciated.


My System SpecsSystem Spec
01 Jan 2013   #2

Windows 7 ultimate x64

If the script is already created in services .... then right click on the service > properties > Stop the service and then on Start Parameters you can add your arguments..

Let me know.
My System SpecsSystem Spec
01 Jan 2013   #3

Windows 7 64 Bit

Getting this Error:

Windows could not start the udp_server service on Local Computer.
Error 1053: The service did not respond to the start or control request in a timely fashion.
My System SpecsSystem Spec

01 Jan 2013   #4

Windows 7 ultimate x64

udp_server ??? is that the one you created ??? Your perl script is trying to call on a dependent udp_server.. it has to be started before you can run your script
My System SpecsSystem Spec
01 Jan 2013   #5

Windows 7 64 Bit

Quote   Quote: Originally Posted by centaur78 View Post
udp_server ??? is that the one you created ??? Your perl script is trying to call on a dependent udp_server.. it has to be started before you can run your script
udp_server is just a name of Perl Script. In other words, I am trying to create a service using SC:

sc create udp_server binpath= C:\Perl\bin\perl.exe type= own start= auto
So udp_server is just a name and nothing else.
My System SpecsSystem Spec
01 Jan 2013   #6

Windows 7 Ultimate x64

Generally speaking, you can't put an arbitrary executable as a Windows service (gives the error you say when starting), as it requires to call an specific interface with the OS to work as a service and respond to the service manager request, which the Perl runner obviously doesn't do. That's what srvany.exe do, provides that interface and runs your arbitrary program in turn. sc.exe is fine for creating the service entry itself.

Why you don't want to use srvany.exe?
I don't think there is another way to run a non-service .exe as a service, unless you make some other program to replace it, or modify the script to call the Windows services API (no idea if that's easy or even possible).
My System SpecsSystem Spec
02 Jan 2013   #7

Windows 7 ultimate x64

You can download the Windows 2003 Resource Kit from MS directly and then follow the below step

1. Copy INSTSRV (Allows you to installs and removes system services) and SRVANY (Allows any Windows application to run as a service.) to the System32 folder under Windows.

2. Run from the cmd as administrator from the C:\Windows\System32 folder

Run MS-DOS command prompt as an administrator as shown below, and run the following command:

INSTSRV <Service Name> C:\Windows\System32\SRVANY.EXE
For example: INSTRV UDP_SERVER C:\Windows\System32\SRVANY.EXE

3. Go to Services menu. and right click on your perl service and set the "Logon As" to Local System Account in the service properties.

4. Go to Regedit, then under

HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Services > UDP_SERVER

Add the new Key: Parameters
Select 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:\DIR_To_Perl\ (your path to the perl script ... this is where you add your extra arguments)

and Close REGEDIT

5. Go back to services and start your UDP_SERVER service.

Let me know if this works
My System SpecsSystem Spec

 Perl file (.pl) file with arguments as windows service

Thread Tools

Similar help and support threads
Thread Forum
Copy file address after doing a file search in windows explorer
Hi All I have a rather large file system with lots of folders & subfolders. When I want to save previously on Xp operating system I'd search in explorer open the folder I want then copy the address (e.g c:\customer records\client name\job address). In windows 7, when I copy the folder address i...
General Discussion
when open a word file or pwrpnt file another file is opens
God bless you, I am not a computer person please help me to fix the problem I have. Every time I open a word, power point and note pad program another file is opens with that (with a infinity sign in the front with the same extension ) is that a thread or how can I stop this thank you...
Microsoft Office
Batch file to start a service if the service is not running
Here what I want : if servicename is running, do nothing. if servicename is not running, then start servicename, then record the date and time. based on my search online, here is what I have so far: net start | find "servicename" > nul 2>&1
General Discussion
Unable to start .jar file as a window service
Hello Everyone, This is my 1st thread, so i'm naive about the categories under which the issue i'm facing falls. I've a jar file which contains a very simple program of displaying "Hello" message in the console.I've pasted the code at the end of this thread.I want to run this jar file as a...
Create a Shortcut with arguments to exe file windows 7
I was trying to add a few shortcuts to my Windows 7 Start Menu and add a command line argument to the short cut. I was able to create a shortcut for "Windows Explorer" using C:\Windows\explorer.exe /n, /e D:\When I tried to create a shortcut for FireFox to select the profile...
General Discussion
Need a software to open .bkf file(windows XP backup file)
i hav recently reinstalled windows 7 from windows xp ..... and i hav created my games backup file ......... but nw i m having a trouble to open it in windows 7...... plz help me
Backup and Restore

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 11:30.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App