Cross Linking: A couple of similar answers:
1)
Chris Painter on service credential preservation and / or handling,2)
Service debugging.
ServiceInstaller classes: This feature is generally meant to be used during development
for testing purposes
. You use the InstallUtil.exe
.NET tool for installation and / or Visual Studio.
Prefer MSI: There are many ways to install services, but you should use the MSI tables ServiceInstall
and ServiceControl
if you can. Below are some further details on various more or less crazy options.
Service Registration Options: An old, classic document from Phil Wilson
(MSI MVP
and author of "The Definitive Guide to Windows Installer"
) listed a number of ways to install services by means of:
1)
MSI –ServiceInstall
,ServiceControl
tables – and a few others.2)
Win32 –CreateService
APIs.3)
Registry – manually update, generally an undesirable “under-the-hood” option.4)
WMI Classes –Win32_Service
. Major benefit: Scriptable. WrapsCreateService
(Win32).5)
InstallUtil.exe – .NET tool & installer classes.6)
MSI & Installer Class Custom Actions – callsInstallUtil.exe
via the shim dllInstallUtilLib.Dll
in Visual Studio Setup Projects – not a favorite option of mine. A lot of complexity for no gain basically. Just use the service tables in the MSI. Automagic.
InstallUtil.exe: When .NET arrived, a tool called InstallUtil.exe was introduced together with a set of installer classes in the .NET framework. The ServiceInstaller framework class contains code to install Services, and the developer can override the class methods to provide extra install-time code. This provides a useful way for developers to easily install Services for testing purposes.
Many years later one could add to Phil’s list:
- SC.exe – https://ss64.com/nt/sc.html
- Regsvcs.exe
- Powershell – New-Service, Set-Service, etc…
More exotic: Srvany (run app as service, very outdated – don’t use).
Essential Service Tools: There are many essential tools for working with services such as: SC.exe
, Services.msc
, NET
, etc...
Process Explorer is good for more advanced debugging – for example what files your service holds locked that cause upgrade problems, or other problems. There is a list of any further tools here: https://installdude.com/jumpgate.php and click the "Debugging"
label (towards top, under search box) and then click "Essential Service Tools"
.
Windows Services Frequently Asked Questions (FAQ): https://www.coretechnologies.com/WindowsServices/FAQ.html