首页 > 解决方案 > wix service install 权限不足

问题描述

我正在尝试使用 WiX 为窗口服务创建安装程序,我尝试了所有我找到的答案,但什么也没有。使用 WiX 创建的安装程序仍然无法安装,因为权限不足,权限不足……这是我的代码……

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'><?define G_TargetDir=$(var.G.TargetDir)?>
    <Product Id="*" Name="G.Installer" Language="1033" Version="1.0.0.0" Manufacturer="" UpgradeCode="PUT-GUID-HERE">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate EmbedCab="yes" />

        <Feature Id="ProductFeature" Title="G.Installer" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="G.Installer" />          
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <Component Id="G.exe" Guid="*">
              <File Id="G.exe" Name="G.exe" Source="$(var.G_TargetDir)G.exe" Vital="yes" KeyPath="yes" />
        <ServiceInstall Id="G.exe" Type="ownProcess" Vital="yes" Name="G.exe" DisplayName="G" Description="Description" Start="auto" Account="LocalSystem" ErrorControl="critical" Arguments="-start" Interactive="yes">
          <util:PermissionEx  User="Everyone" ServicePauseContinue="yes" ServiceQueryStatus="yes" ServiceStart="yes" ServiceStop="yes" ServiceUserDefinedControl="yes" />
        </ServiceInstall>
        <ServiceControl Id="G.exe" Stop="both" Start="install" Remove="uninstall" Name="G.exe" Wait="no"/>
            </Component>
            <Component Id="G.exe.config" Guid="*">
              <File Id="G.exe.config" Name="G.exe.config" Source="$(var.G_TargetDir)G.exe.config" />
            </Component>
            <Component Id="MongoDB.Bson.dll" Guid="*">
              <File Id="MongoDB.Bson.dll" Name="MongoDB.Bson.dll" Source="$(var.G_TargetDir)MongoDB.Bson.dll" />
            </Component>
            <Component Id="System.Buffers.dll" Guid="*">
              <File Id="System.Buffers.dll" Name="System.Buffers.dll" Source="$(var.G_TargetDir)System.Buffers.dll" />
            </Component>
            <Component Id="DnsClient.dll" Guid="*">
              <File Id="DnsClient.dll" Name="DnsClient.dll" Source="$(var.G_TargetDir)DnsClient.dll" />
            </Component>
            <Component Id="System.Runtime.InteropServices.RuntimeInformation.dll" Guid="*">
              <File Id="System.Runtime.InteropServices.RuntimeInformation.dll" Name="System.Runtime.InteropServices.RuntimeInformation.dll" Source="$(var.G_TargetDir)System.Runtime.InteropServices.RuntimeInformation.dll" />
            </Component>
            <Component Id="MongoDB.Driver.Core.dll" Guid="*">
              <File Id="MongoDB.Driver.Core.dll" Name="MongoDB.Driver.Core.dll" Source="$(var.G_TargetDir)MongoDB.Driver.Core.dll" />
            </Component>
            <Component Id="MongoDB.Driver.dll" Guid="*">
              <File Id="MongoDB.Driver.dll" Name="MongoDB.Driver.dll" Source="$(var.G_TargetDir)MongoDB.Driver.dll" />
            </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

标签: xmlservicewixwindows-services

解决方案


InstallPrivileges:在尝试其他任何操作之前,您能否 InstallPrivileges attributePackage 元素的 设置为"elevated"?只是为了确保 - 我认为提升是默认值(至少一旦 InstallScope 是 perMachine?)。


编译?: 不太清楚会发生什么。WiX 项目是否无法编译?看起来很奇怪的第一件事是您没有制造商价值-也许您在发布之前对其进行了编辑?据我所知,除非Manufacturer有值,否则 WiX 3 将拒绝编译。如果缺少,请添加。

<Product Id="*" Name="G.Installer" Language="1033" Version="1.0.0.0" 
         Manufacturer="YOURCOMPANYNAMEHERE" UpgradeCode="PUT-GUID-HERE">

安装行为:如果安装编译,运行时是否开始安装,但未能完成?或者它是否完成并且服务无法启动?您是否使用管理员帐户安装并在开始安装时收到 UAC 提示?


日志记录:我们需要更多信息,如果安装失败,您应该启用 MSI 日志记录以查看发生了什么。首先检查系统的事件日志,然后在启用详细 MSI 日志记录的同时运行安装。我喜欢为所有 MSI 安装启用日志记录。对性能的影响很小,但是当您突然需要一个真正的日志文件时,它总是可用的。您可以按照 installsite.org 上的说明启用所有 MSI 文件的日志记录(部分:“全局用于机器上的所有设置”)。然后 MSI 日志文件将位于您的%TEMP% folder安装后。它们有一个随机的十六进制名称,您可以定期冲洗它们,以免它们堆积起来。您按修改日期/时间排序以找到最新创建的 - 显然。可以在此处找到一些日志记录和日志文件解释提示


建议:1: 我会尝试设置在虚拟机上手动运行服务所需的文件并注册它们以验证服务运行没有问题。2:完全重建 WiX 设置,删除任何临时文件和wixobj 文件。您的安装程序可能只是没有编译,但它与wixobj先前编译的预先存在的文件链接。“高度惊讶”因素(与过时文件链接)。


服务启动问题:而且很明显:如果服务无法启动,请启用其最大日志记录级别并检查事件日志以及您可能拥有的任何其他日志记录。运行依赖项检查Dependencies.exe-rewrite ofDependency Walker)并检查程序集绑定检查配置文件中的 dev-box错误(硬编码的错误值),等等......不需要告诉你,但这是我通常的清单(有人出于某种原因投反对票,让我知道你有什么错误也许在那里找到?我是部署专家而不是编码员 - 它更像是“想法”列表而不是真正的清单)。


源代码简化:WiX 源文件通常可以按照此处的说明进行简化: WIX 中 guid 的语法?样本:

<Component Id="System.Runtime.InteropServices.RuntimeInformation.dll" Guid="{00000000-0000-0000-0000-000000000000}">
   <File Id="System.Runtime.InteropServices.RuntimeInformation.dll" Name="System.Runtime.InteropServices.RuntimeInformation.dll" Source="$(var.G_TargetDir)System.Runtime.InteropServices.RuntimeInformation.dll" />
 </Component>

对比

<Component>
   <File Source="$(var.G_TargetDir)System.Runtime.InteropServices.RuntimeInformation.dll" />
 </Component>

推荐阅读