I have a requirement to launch an executable as a windows service with help of procrun.
I followed the below steps.
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
batchSample.bat
, to launch a URL:start https://www.youtube.com/watch?v=q3pG6b3uI_E
batchSample.exe
, and placed it in C:\Program Files (x86)\Test
. 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.