Search code examples
windows-servicesinno-setup

Install a service on Windows (Vista/XP/7) using Inno Setup


I need to install and run a service when install an application (installer.exe is created using Inno Setup)

I used codes below

[Run]
Filename:"{sys}\myservice.exe "; Parameters: "-install"

I am not sure if this is correct

(I add codes to reminder reboot but I wonder if it is possible to run the service immediately after installation without reboot pc.)

[Setup]
AlwaysRestart=yes

Welcome any comment.


Solution

    1. Use sc.exe, It is simple, the only drawback is you may have to intercept and parse output to know what went wrong, if it did.
    2. Use my Inno Setup service library. It's a Pascal Script wrapper over the SCM API, and let you to control the services fully. A little more complex to use, but it allows for full error checking and handling. There are some higher level functions designed to display errors in standard suppressible Inno Setup dialog boxes.

    PS: don't install your service in any of the Windows systems folder. They should be regarded as Windows private folders. Unless you have very, very good reasons to write there (i.e. drivers), you should never install software there. Install it in your application folders.