代码之家  ›  专栏  ›  技术社区  ›  A.Pissicat

Wix安装程序无法启动服务

  •  1
  • A.Pissicat  · 技术社区  · 6 年前

    我创建了一个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>
    

    当我尝试安装服务时,出现错误:

    服务“我的服务”(My Service)无法启动。确认您 有足够的权限启动系统服务

    我看到这个错误是一个普通的错误。所以我忽略了。在我的 INSTALLFOLDER 我有所有的文件。然后我启动services.msc并尝试启动我的服务。错误是:

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

    我想知道更多细节,但找不到问题所在。我怎样才能修好这个?

    1 回复  |  直到 6 年前
        1
  •  1
  •   A.Pissicat    6 年前

    我终于找到了问题所在。

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

    我通过添加 KeyPath 在.exe上:

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