0

I am invoking sc.exe from my installer:

[SystemFolder]cmd.exe /c sc create ...

to start a Windows service, but all I know is that the service does not start.

What can I use instead of cmd.exe in order to see the output of the sc command (and the command itself, if possible)?

porton
  • 5,214
  • 11
  • 47
  • 95

1 Answers1

0

What type of installer is this? MSI installers should use the ServiceInstall and ServiceControl tables to install and control a service binary. This is all "automagic" and works very reliably if you follow the correct procedure. There is no need to use a custom action to install a Windows Service with MSI.

WiX: If you are using WiX, here are some resources to help you install services:


Advanced Installer: If you are not using WiX, here is a section on Advanced Installer and service installation:


Service Launch Failure Debugging: If you have problems starting the service at all (even without an installer - for example on a clean virtual), please review the below check lists for potential problems (the most common startup problems are usually: missing runtimes, permission problems, missing files, bitness problems x86 64, error in configuration files, etc... old answer on this):


Further Links:

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • I create an MSI using WiX. I need to use `sc.exe`, because I do not have a binary specifically suited for usage as a Windows service. As far as I understand, I need *both* to install a service using `ServiceInstall`&`ServiceControl` and to manually create and start it using `sc.exe`. – porton Mar 22 '23 at 08:04
  • What are you using to make the binary run as a service? I don't use this kind of stuff, but I know about [Srvany](https://www.coretechnologies.com/WindowsServices/FAQ.html#WhatIsSrvany). I know there are [several common Srvany problems](https://www.coretechnologies.com/blog/srvany/top-3-srvany-problems/) and I believe the tool has not been updated in a long time (I didn't check recently). If this is your own binary I would seriously consider making it a proper service. – Stein Åsmul Mar 22 '23 at 17:00
  • I am not familiar with [AlwaysUp](https://www.coretechnologies.com/products/AlwaysUp/) either. Here is [a list of further Srvany problems](https://www.coretechnologies.com/products/AlwaysUp/srvany.html). – Stein Åsmul Mar 22 '23 at 17:29
  • And in my notes I found [TopShelf](https://github.com/Topshelf/Topshelf). Never tried it. Perhaps you use it already? Github project is set read-only. (*"Topshelf is a framework for hosting services written using the .NET framework. The creation of services is simplified, allowing developers to create a simple console application that can be installed as a service using Topshelf. The reason for this is simple: It is far easier to debug a console application than a service."*) – Stein Åsmul Mar 22 '23 at 17:59