Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup: Installing Windows services using "sc create"

Tags:

inno-setup

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 not work for me. It's getting stuck at the end of the installation. What am I doing wrong?

Here is my code:

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

I tried using cmd instead of {cmd} - no change.

I did not try the Pascal code in the solution which I referred. I am keeping it as the last resort.

like image 905
rgm Avatar asked May 13 '13 08:05

rgm


People also ask

How do I Setup Inno Setup?

Go to Menu, Project, then Compile to compile and create the setup file. This will create a complete installer. Run the Setup and your application will be installed correctly. Innosetup offers an awesome alternative to create great looking Installers for free.

What is Inno Setup used for?

The installer has the ability to compare file version info, replace in-use files, use shared file counting, register DLL/OCXs and type libraries, and install fonts. * Creation of shortcuts, including in the Start Menu and on the desktop.

Does Inno Setup work on Linux?

You're in luck: It's possible to run Inno Setup anywhere that Docker runs (including Linux and macOS), and even have a passable experience writing your setup script.


2 Answers

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

like image 139
rgm Avatar answered Sep 16 '22 19:09

rgm


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.

like image 35
Deanna Avatar answered Sep 18 '22 19:09

Deanna