交联: 几个类似的答案:1)
Chris Painter 谈服务凭证保存和/或处理 https://stackoverflow.com/a/61882958, 2)
服务调试 https://stackoverflow.com/a/61149858/129130.
服务安装程序类:此功能通常在以下情况下使用development
for testing purposes
。您使用InstallUtil.exe
用于安装和/或 Visual Studio 的 .NET 工具。
更喜欢微星:安装服务的方法有很多,但你应该使用MSI表ServiceInstall
and ServiceControl
如果可以的话。以下是有关各种或多或少疯狂的选项的更多详细信息。
服务注册选项: 一份古老的经典文件Phil Wilson
(MSI MVP
和作者"The Definitive Guide to Windows Installer" https://rads.stackoverflow.com/amzn/click/com/1590592972)列出了多种安装服务的方法:
-
1)
MSI - ServiceInstall
, ServiceControl
tables - and a few others.
- WiX service installation sample 1 https://github.com/rstropek/Samples/tree/master/WiXSamples/WindowsService
- WiX service installation sample 2 https://github.com/Robs79/How-to-create-a-Windows-Service-MSI-Installer-Using-WiX
-
2)
Win32 - CreateService
APIs.
-
3)
Registry- 手动更新,通常是不受欢迎的“幕后”选项。
-
4)
WMI 类 - Win32_Service
。主要好处:可编写脚本 https://www.vbsedit.com/scripts/os/services/. Wraps CreateService
(Win32)。
-
5)
安装实用程序- .NET 工具和安装程序类。
-
6)
MSI 和安装程序类自定义操作- 打电话InstallUtil.exe
通过 shim dllInstallUtilLib.Dll
在 Visual Studio 安装项目中 - 这不是我最喜欢的选项。很多复杂性基本上没有任何收获。只需使用 MSI 中的服务表即可。自动魔法。
安装实用程序:当 .NET 出现时,在 .NET 框架中引入了一个名为 InstallUtil.exe 的工具以及一组安装程序类。 ServiceInstaller 框架类包含用于安装服务的代码,开发人员可以重写类方法以提供额外的安装时代码。这为开发人员轻松安装服务以进行测试提供了一种有用的方法。
许多年后,人们可以在菲尔的清单中添加以下内容:
-
SC.exe https://support.microsoft.com/en-us/help/251192/how-to-create-a-windows-service-by-using-sc-exe - https://ss64.com/nt/sc.html https://ss64.com/nt/sc.html
- 注册表文件 https://learn.microsoft.com/en-us/dotnet/framework/tools/regsvcs-exe-net-services-installation-tool
-
电源外壳 - 新服务 https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-service?view=powershell-7, 设定服务 https://ss64.com/ps/set-service.html, etc...
更奇特的是:Srvany(将应用程序作为服务运行,非常过时 - 不要使用)。
基本服务工具:有许多用于使用服务的基本工具,例如:SC.exe
, Services.msc
, NET
, etc...
流程浏览器 https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer有利于更高级的调试 - 例如,您的服务锁定哪些文件导致升级问题或其他问题。这里有一个其他工具的列表:https://installdude.com/jumpgate.php https://installdude.com/jumpgate.php并单击"Debugging"
标签(朝顶部,在搜索框下方),然后单击"Essential Service Tools"
.
Windows 服务常见问题解答 (FAQ):https://www.coretechnologies.com/WindowsServices/FAQ.html https://www.coretechnologies.com/WindowsServices/FAQ.html