Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

installing windows service with SC.exe or InstallUtil.exe - there is difference but which?

SC.exe and InstallUtil both install/uninstall windows services. But they don't seem to work the same way.

What is the difference?


For instance InstallUtil fails (some file or dependency not found error) while Sc create happily installs the service. Too add to the strangeness; the service doesn't show up if I run net start in the console. But it does show up in the services GUI. Variants of this happen when I try to uninstall.

I have written the service myself and earlier versions work. Dotnet3.5.

like image 683
LosManos Avatar asked Jan 14 '11 14:01

LosManos


People also ask

What is the difference between InstallUtil and SC?

What is the difference? For instance InstallUtil fails (some file or dependency not found error) while Sc create happily installs the service.

What is the use of InstallUtil exe?

Installutil.exe detects and executes these installer components. You can specify multiple assemblies on the same command line. Any option that occurs before an assembly name applies to that assembly's installation. Except for /u and /AssemblyName , options are cumulative but overridable.

How do I install a Windows service with a different name?

You need to copy your service executable to a separate directory and use InstallUtil.exe to give it a different service name. From a command prompt, you'll need to use InstallUtil to install both instances of your service. For instructions on how to use InstallUtil, see Installer Tool (InstallUtil.exe).


2 Answers

Yes, installing a service isn't particularly complicated. It just takes writing a handful of registry keys. You can have a look-see with Regedit.exe, navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services.

Sc.exe can write these keys too, using the supplied command line arguments. Nevertheless, this is not the right way to do it. The point of InstallUtil.exe is that it can activate custom installation code. Code that the service author wrote. Which is not that uncommon, services tend to stuff config info in their registration keys for their own use. You'll see plenty of evidence for that when you have a look with Regedit.

like image 92
Hans Passant Avatar answered Sep 21 '22 15:09

Hans Passant


I prefer sc.exe over installutil.exe.

InstallUtil forces you to add the dreadful ProjectInstaller class (I believe) and hardcode there the service name and service description.

InstallUtil makes it very hard to put two versions of the same service running in the same machine at the same time.

That's why I just don't use InstallUtil.exe at all. Also because of previous responses: you need it to be in your deploy package. sc.exe is already in any Windows Xp and above (I believe).

like image 21
Kat Lim Ruiz Avatar answered Sep 23 '22 15:09

Kat Lim Ruiz