Wix 安装程序无法启动服务



我创建了一个Wix安装程序来安装服务。有我的产品.wxs :

<?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>

当我尝试安装我的服务时,我有错误:

服务

"我的服务"(我的服务(无法启动。 验证您是否 具有足够的权限来启动系统服务

我看到此错误是一般错误。所以我忽略了它。在我的INSTALLFOLDER里,我有所有的文件。然后我启动了services.msc并尝试启动我的服务。错误是:

无法在本地计算机上启动该服务。错误 193:0xc1

我试图了解更多细节,但我找不到问题所在。我该如何解决这个问题?

我终于发现了问题所在。

在我的服务属性中,我看到服务路径指向MyService.exe.config

我通过在.exe上添加KeyPath来解决问题:

<File Id="MyService.exe"
      Name="$(var.service).exe"
      Source="$(var.MyService.TargetDir)$(var.service).exe"
      Vital="yes"
      KeyPath="yes"/>

相关内容

最新更新