Alican Selanik
Alican Selanik

Reputation: 31

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?

Upvotes: 3

Views: 2171

Answers (1)

M.A_55
M.A_55

Reputation: 145

  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

Upvotes: 4

Related Questions