I have a requirement to launch an executable as a windows service with help of procrun.
I followed the below steps.
- Created a batch-file named
run.bat, to create a service.
"C:\Program Files (x86)\Test\prunsrv.exe" //IS//Test --DisplayName="Test" --Startup=auto --Install="C:\Program Files (x86)\Test\prunsrv.exe" --StartMode=exe --StartImage="C:\Program Files (x86)\Test\batchSample.exe" --LogPath="C:\Program Files (x86)\Test\logs" --StdOutput=auto --StdError=auto
- Created a batch-file,
batchSample.bat, to launch a URL:
start https://www.youtube.com/watch?v=q3pG6b3uI_E
- Converted the batch-file to an executable,
batchSample.exe, and placed it inC:\Program Files (x86)\Test. - Executed
run.bat.
At this point the the windows service, Test started without giving any error, but it did not execute the batchSample.exe as used for --StartImage.
Appreciate your help.
Your batch file is not an executable, no matter what extension you give it.
Per the docs - https://commons.apache.org/proper/commons-daemon/procrun.html
--StartImage Executable that will be run. Only applies to exe mode.
++StartParams List of parameters that will be passed to either StartImage or StartClass. Parameters are separated using either # or ; character.
You need a program to execute your batch file as StartImage (sh?), and put the batch file in StartParams.