我有一个使用WiX引导程序设置的C#应用程序。此安装程序安装SQL Server和我的应用程序。此应用程序是一个带有自定义服务的旧应用程序:public partial class MyCustomService : System.ServiceProcess.ServiceBase
。
以前,此服务是使用Windows Installer(System.Configuration.Install.Installer
)安装的。我修改了项目以使用WiX。现在服务应该像这样开始:
<Component Id="MyCustomService" Guid="{THE-GUID}" KeyPath="yes">
<!-- service will need to be installed under Local Service -->
<ServiceInstall
Id="MyCustomService"
Type="ownProcess"
Vital="yes"
Name="MyCustomService"
DisplayName="My Custom Service"
Description="Service Custom"
Start="auto"
Account="NT AUTHORITY\LocalService"
ErrorControl="normal"/>
<ServiceControl Id="MyCustomService_Start" Name="MyCustomService" Start="install" Wait="no" />
<ServiceControl Id="MyCustomService_Stop" Name="MyCustomService" Stop="both" Wait="yes" Remove="uninstall" /> />
<RegistryKey Root="HKLM" Key="Software\MyCustomService" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="expandable"/>
</RegistryKey>
<RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\services\eventlog\Application\MyCustomService" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="expandable"/>
</RegistryKey>
</Component>
编辑:
我终于通过了异常。该服务尝试启动但刚刚停止。我在日志事件中看到:“访问注册表项'HKEY_LOCAL_MACHINE \ Software \ MyCustomService'已被拒绝。
在创建注册表项时,有没有办法为所有人设置权限?