我创建了一个Wix设置来安装服务。这是我的产品。wxs:
looks-like-this
当我尝试安装服务时,出现错误:
服务“我的服务”(MyService)无法启动。验证你 有足够的特权来启动系统服务
我看到此错误是一般错误。所以我忽略了它。我的<?xml version="1.0" encoding="UTF-8"?>
<?define compagny = "MyCompagny"?>
<?define product = "My Service"?>
<?define service = "MyService"?>
<?define version = "!(bind.FileVersion.MyService.exe)"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="$(var.product)"
Language="1033"
Version="$(var.version)"
Manufacturer="$(var.compagny)"
UpgradeCode="XXXXXXX">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Media Id="1" Cabinet="MyService.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="CPGNYFOLDER" Name="$(var.compagny)">
<Directory Id="INSTALLFOLDER" Name="$(var.product)" >
<Directory Id="Service_tessdata" Name="tessdata"/>
<Directory Id="Service_x64" Name="x64"/>
<Directory Id="Service_x86" Name="x86"/>
</Directory>
</Directory>
</Directory>
</Directory>
<ComponentGroup Id="InstallComponents">
<Component Id="InstallService" Guid="XXXXXXX" Directory="INSTALLFOLDER">
<File Id="MyService.exe.config"
Name="$(var.service).exe.config"
Source="$(var.MyService.TargetDir)\$(var.service).exe.config"
Vital="yes"/>
<File Id="MyService.exe"
Name="$(var.service).exe"
Source="$(var.MyService.TargetDir)\$(var.service).exe"
Vital="yes"/>
<!-- Install all dll -->
<RemoveFile Id="ALLFILES" Name="*.*" On="both" />
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Vital="yes"
Name="$(var.service)"
DisplayName="$(var.product)"
Description=""
Start="auto"
Account="LocalSystem"
ErrorControl="normal" />
<ServiceControl Id="Service_Start" Name="MyService" Start="install" Wait="no" />
<ServiceControl Id="Service_Stop" Name="MyService" Stop="both" Remove="uninstall" Wait="yes" />
</Component>
<!-- Install all directories -->
</ComponentGroup>
<!-- Tell WiX to install the files -->
<Feature Id="ProductFeature" Title="$(var.product)" Level="1">
<ComponentGroupRef Id="InstallComponents" />
</Feature>
</Product>
</Wix>
中有所有文件。然后,我启动了services.msc并尝试启动我的服务。错误是:
无法在本地计算机上启动服务。错误193:0xc1
我尝试提供更多详细信息,但我找不到问题所在。我该如何解决?
答案 0 :(得分:1)
我终于找到了问题所在。
在我的服务属性中,我看到服务路径指向MyService.exe.config
。
我通过在.exe上添加KeyPath
来解决此问题:
<File Id="MyService.exe"
Name="$(var.service).exe"
Source="$(var.MyService.TargetDir)\$(var.service).exe"
Vital="yes"
KeyPath="yes"/>