简体   繁体   中英

Inno setup and NSSM service working integration

I have an application to pack into a setup file with Inno setup. Application must work as a service on Windows. I am using NSSM service manager to get it done in single computer. However in Inno setup package, I couldn't find any trick to make it possible.

Is there anything to do it with NSSM or is it possible to make service working with Inno script?

  1. Download NSSM
  2. Extract Zip file, then copy nssm.exe to your source path (which Inno Setup script get sources from).
  3. Create a bat file to allow nssm set your App as a service as below:

     nssm install "ServiceName" "YourAPP.EXE" nssm set "ServiceName" AppDirectory %CD% nssm start "ServiceName" del "%~f0"

    Note: del "%~f0" to delete bat file after setup finished, if you don't want that, remove that line from bat file

  4. Add the previous bat file in your source path.

  5. Add new sources to Inno Setup script as below:

     [Files] Source: "..\\YOUR-SOURCE-PATH\\file.bat"; DestDir: "{app}"; Source: "..\\YOUR-SOURCE-PATH\\nssm.exe"; DestDir: "{app}";
  6. Add bat file under [Run] section to set service and start your app as below:

     Filename: "{app}\\file.bat"; \\ Flags: nowait postinstall hidewizard runhidden runascurrentuser; \\ Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"

I hope it be useful, have to thank @MartinPrikryl

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM