安装Windows服务的SC.exe或InstallUtil.exe - 有差异,但哪个?差异、SC、Windows、InstallUtil

2023-09-02 10:55:19 作者:风华笔墨、

的SC.exe 和 InstallUtil 的两个安装/卸载Windows服务。但他们似乎并不相同的方式工作。

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

有什么区别?

例如 InstallUtil 的失败(某些文件或依赖项未找到错误),而钪创建的愉快安装服务。太添加到陌生感;该服务不出来,如果​​我在控制台中运行的网络启动的。但它确实显示在服务界面。 这种变异发生时,我尝试卸载。

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.

我已经写了自己和更早版本的工作服务。 Dotnet3.5。

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

推荐答案

是的,安装服务不是特别复杂。它只是需要编写少量的注册表项。你可以有REGEDIT.EXE看看,看看,定位到HKEY_LOCAL_MACHINE 系统 CurrentControlSet 服务。

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可以写这些按键也使用提供的命令行参数。不过,这是不正确的方式来做到这一点。 InstallUtil.exe的一点是,它可以激活的自定义的安装code。 code。该服务的作者写道。这是不是少见,服务往往东西在他们的注册键配置信息为自己所用。你会看到大量的证据表明,当你有注册表编辑器看一下。

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.