2

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?

Seanny123
  • 8,776
  • 13
  • 68
  • 124
  • I've done it in the past. What problem are you having? Post your script and what behavior you're seeing. – mirtheil May 03 '16 at 12:35
  • @mirtheil actually i couldnt even add any code into script about NSSM. I couldnt find any examples about it. – Alican Selanik May 03 '16 at 12:36
  • Nor would I expect any specific examples of NSSM and InnoSetup. What you need to do is get the NSSM part working on its own and then integrate that into InnoSetup. I can tell you that all I did was include the NSSM executable in my scrip and add a [RUN] entry. – mirtheil May 03 '16 at 13:02
  • @mirtheil is it possible to write my own script (.bat) to create service via NSSM. Because while creating service, nssm interface is being opened and it is an obstacle to do that via .bat file ? Is that so, what do you think? – Alican Selanik May 03 '16 at 14:11

1 Answers1

3
  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

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
M.A_55
  • 135
  • 17
  • try to highlight the keywords and be clear with the format it will help to reach out your answer for others – Agilanbu Dec 10 '18 at 09:22
  • It's my first answer, i don't know why it was appearing like that, i set codes flags and wrote it into steps organized – M.A_55 Dec 10 '18 at 09:29
  • 1
    its okay all are like that only. will correct it by your upcoming contribution. all the best. – Agilanbu Dec 10 '18 at 09:49