Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
767 views
in Technique[技术] by (71.8m points)

.net - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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_MACHINESYSTEMCurrentControlSetservices.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...