windowsbatch-fileserviceexecutableprocrun

Unable to launch a packaged executable as a Windows service via ProcRun


I have a requirement to launch an executable as a with help of .

I followed the below steps.

  1. Created a 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
  1. Created a , batchSample.bat, to launch a URL:
start https://www.youtube.com/watch?v=q3pG6b3uI_E
  1. Converted the to an , batchSample.exe, and placed it in C:\Program Files (x86)\Test.
  2. 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.


Solution

  • 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.