Inno Setup: Installing Windows services using “sc create”

后端 未结 2 1255
清歌不尽
清歌不尽 2020-12-16 00:16

I have two binaries and have to create a service for them. I tried a solution using \"sc create\" from How to install a Windows service with Inno Setup?

But it did n

相关标签:
2条回答
  • 2020-12-16 00:44

    I used this code and both of my services are installing and uninstalling:

    [run]
    Filename: {sys}\sc.exe; Parameters: "create mysrv start= auto binPath= ""{app}\mysrv.exe""" ; Flags: runhidden
    
    [UninstallRun]
    Filename: {sys}\sc.exe; Parameters: "stop mysrv" ; Flags: runhidden
    Filename: {sys}\sc.exe; Parameters: "delete mysrv" ; Flags: runhidden
    

    This solved my problem, so why should I use Pascal in this case.?

    0 讨论(0)
  • 2020-12-16 01:04

    Is there any reason you're trying to run it through {cmd}?

    Either add the /C parameter and quote the rest as required, or just run sc.exe with the required parameters.

    [Run]
    Filename: "sc.exe"; Parameters: "create srvname start= auto DisplayName= mysrv binPath= {app}\mybinary.exe" ; Flags: runhidden 
    

    Note that the correct way to install the service is the API as mentioned in this answer that will allow you to detect and handle errors.

    0 讨论(0)
提交回复
热议问题