I want to be able to install a windows service using installutil.exe and then run and stop/delete T.myService.exe automatically from innosetup script. I tried the below code
[Run]
Filename: "{dotnet40}\InstallUtil.exe"; WorkingDir: "{app}"; Parameters: "T.myService.exe" ; Flags: runhidden
[UninstallRun]
Filename: "{dotnet40}\InstallUtil.exe"; Parameters: "stop T.myService.exe" ; Flags: runhidden
Filename: "{dotnet40}\InstallUtil.exe"; Parameters: "delete T.myService.exe" ; Flags: runhidden
The above just shows my T.myService.exe in TaskManager/services.msc but the status is "stopped". They don't seem to run automatically. I will have to manually right click on T.myService.exe in task manager to make them run or with the below command in the command prompt
To install a service
<path>\InstallUtil.exe <path to T.myService.exe>
To uninstall a service
<path>\InstallUtil.exe /u <path to T.myService.exe>
But, I want the service to start running automatically once the install completes and when I uninstall all traces of T.myService.exe should be gone. With my innosetup code, it doesn't run and stop/delete automatically. I also enabled [UninstallDelete] to delete my T.myService.exe explicitly which removes all associated files from the app directory but the service is still seen in the task manager/services.msc which is a problem.
What am I missing? What should I be doing to run and stop/delete the service automatically?