You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WiX Toolset MSI安装包RDP远程无法启动Windows服务问题排查

用例

我需要为一款名为Z的软件编写基于WiX Toolset的MSI安装程序。
Z基于ASP.NET Web API Core 6.0开发,用于两台机器(命名为C和S)之间的数据交互。我的任务是在机器C上安装Z。
团队成员在本地Windows 10笔记本上测试安装,一切正常。但成员M没有Windows设备,他通过远程Windows Server 2012机器(命名为W)安装MSI包时遇到问题。
经过两三周排查,我们用Windows笔记本远程连接Windows Server 2016备用服务器测试,确认了问题:通过RDP(终端服务或mstsc /admin)安装时,MSI安装失败。


Z的细节

以下是定义Z的Windows服务部署方式的ProductComponents.wxs文件:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <!-- Customizable component group -->
    <ComponentGroup Id="ProductComponents" Directory="APPLICATIONFOLDER">
      <ComponentRef Id="WindowsServiceComponent" />
      <ComponentRef Id="RemoveFolderComponent" />
    </ComponentGroup>

    <!-- Removal of the install folder when uninstalling the product -->
    <!-- and (un)installation of Z as a Windows Service -->
    <DirectoryRef Id="APPLICATIONFOLDER">
        
      <!-- Removal of the folder -->
      <Component Id="RemoveFolderComponent" Guid="{snipped}">
        <RemoveFolder Id="RemoveInstallFolder" Directory="APPLICATIONFOLDER" On="uninstall" />
      </Component>
            
      <!-- (Un)installation of Z's Windows Service -->
      <Component Id="WindowsServiceComponent" Guid="{snipped}">
        <File Id="fil87B519F6CA084815922D1FED42E5B4AD" Source="$(var.PublishDir)\Z.exe" KeyPath="yes" Vital="yes" />
        <ServiceInstall Id="WindowsServiceInstall" Name="Z" DisplayName="!(loc.ProductName_$(var.Platform))" Description="!(loc.WindowsServiceDescription)" Start="auto" Type="ownProcess"
          ErrorControl="normal" />
        <ServiceControl Id="StartService" Name="Z" Start="install" Stop="both" Remove="uninstall" Wait="yes" />
      </Component>

    </DirectoryRef>
  </Fragment>
</Wix>

以下是向WiX定义Z产品信息的Product.wxs文件:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    
  <!-- Fixed upgrade ID (do *NOT* change it) -->
  <?define UpgradeCode = "{someguid}"?>

  <!-- Declare Z -->
  <Product Id="*" Name="!(loc.ProductName_$(var.Platform))" Language="!(loc.Language)" Version="$(var.BuildVersion)" 
      Manufacturer="!(loc.CompanyName)" UpgradeCode="$(var.UpgradeCode)">
        
    <!-- Provide package details -->
    <Package Compressed="yes" InstallScope="perMachine"
        Platform="$(var.Platform)"
        Manufacturer="!(loc.CompanyName)"
        Description="!(loc.PackageDescription)"
        Keywords="!(loc.PackageKeywords)"
        Comments="!(loc.PackageComments)"
        InstallPrivileges="elevated" />

    <!-- Upgrade -->
    <Property Id="PREVIOUSVERSIONSINSTALLED" Value="0" />
    <Upgrade Id="$(var.UpgradeCode)">
      <UpgradeVersion Minimum="1.0.0.0" Maximum="$(var.BuildVersion)" Property="PREVIOUSVERSIONSINSTALLED" />
    </Upgrade>
    <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeErrorMessage)" AllowDowngrades="no"
      AllowSameVersionUpgrades="yes" IgnoreRemoveFailure="no" Schedule="afterInstallInitialize"  />
        
    <!-- Include .cab file into the .msi file -->
    <MediaTemplate EmbedCab="yes" />
        
    <!-- Use the icon.ico icon for this installer (shows up in Add/Remove Programs) -->
    <Icon Id="MyBeautifulIcon" SourceFile="Assets\icon.ico" />
    <Property Id="ARPPRODUCTICON" Value="MyBeautifulIcon" />
        
    <!-- Help/Support website (shows in the Add/Remove Programs) -->
    <Property Id="ARPURLINFOABOUT">http://www.z-enterprise.co.jp/</Property>

    <!-- Disable Change/Repair buttons -->
    <Property Id="ARPNOREPAIR" Value="yes" Secure="yes" />
    <Property Id="ARPNOMODIFY" Value="yes" Secure="yes" />
        
    <!-- Define components (files, shortcuts, Windows Services, etc.) -->
    <Feature Id="RootFeature" Title="Z" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentGroupRef Id="AutoGeneratedComponents" />
    </Feature>

    <UIRef Id="InstallerUI"/>

    <!-- Custom actions and their order of execution 
    See more at https://learn.microsoft.com/en-us/windows/win32/msi/standard-actions-reference -->
    <InstallUISequence>
      <Custom Action="ReadSettingsAction" After="CostFinalize" />
    </InstallUISequence>
    <InstallExecuteSequence>
      <Custom Action="CheckSettingsAction" After="InstallInitialize" />
      <Custom Action="SetPropertyAction" After="CheckSettingsAction" />
            
      <!-- The condition NOT REMOVE below skips the custom action during uninstall -->
      <Custom Action="SaveSettingsAction" Before="InstallServices"><![CDATA[NOT REMOVE]]></Custom>
    </InstallExecuteSequence>
        
    <!-- Enable verbose log mode for the installer. Logs are saved at %temp%\MSI{random chars}.LOG. -->
    <Property Id="MsiLogging" Value="v" />
  </Product>
</Wix>

运行MSI安装程序的Windows用户是本地管理员,该用户可以安装Windows服务,但无法启动服务。

以下是安装失败时的MSI日志:

MSI (s) (04:F8) [07:59:44:887]: Created Custom Action Server with PID 6620 (0x19DC).
MSI (s) (04:5C) [07:59:44:887]: Executing op: ActionStart(Name=StartServices,Description=Starting services,Template=Service: [1])
MSI (s) (04:5C) [07:59:44:887]: Executing op: ProgressTotal(Total=1,Type=1,ByteEquivalent=1300000)
MSI (s) (04:5C) [07:59:44:887]: Executing op: ServiceControl(,Name=Z,Action=1,Wait=1,)
MSI (s) (04:4C) [07:59:44:902]: Running as a service.
MSI (s) (04:4C) [07:59:44:902]: Hello, I'm your 64bit Elevated Non-remapped custom action server.
SFXCA: Extracting custom action to temporary directory: C:\Windows\Installer\MSIBE30.tmp-\
SFXCA: Binding to CLR version v4.0.30319
Calling custom action Z.CustomActions!Z.CustomActions.CustomActions.SaveSettings
Begin SaveSettings().
SaveSettings() has finished.
1: SaveSettingsAction 2: 0 
MSI (s) (04:5C) [08:00:15:014]: Note: 1: 2205 2:  3: Error 
MSI (s) (04:5C) [08:00:15:014]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1920 
MSI (s) (04:94) [08:00:30:142]: I/O on thread 1524 could not be cancelled. Error: 1168
MSI (s) (04:94) [08:00:30:142]: I/O on thread 6288 could not be cancelled. Error: 1168
MSI (s) (04:94) [08:00:30:142]: I/O on thread 7668 could not be cancelled. Error: 1168
MSI (s) (04:94) [08:00:30:142]: I/O on thread 1356 could not be cancelled. Error: 1168
MSI (s) (04:94) [08:00:30:142]: I/O on thread 8044 could not be cancelled. Error: 1168
MSI (s) (04:94) [08:00:30:142]: I/O on thread 8284 could not be cancelled. Error: 1168
MSI (s) (04:94) [08:00:30:142]: I/O on thread 4088 could not be cancelled. Error: 1168
MSI (s) (04:5C) [08:00:30:142]: Note: 1: 2205 2:  3: Error 
MSI (s) (04:5C) [08:00:30:142]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709 
MSI (s) (04:5C) [08:00:30:142]: Product: Z (64-bit) -- Error 1920. Service 'Z (64-bit)' (Z) failed to start.  Verify that you have sufficient privileges to start system services.

这些1168错误引起了我的注意,我怀疑Z尝试调用.NET Runtime,因此安装了ASP.NET Core Runtime 6.0,但问题仍未解决。


其他疑问
  • 是否存在Active Directory管理的GPO限制用户启动Windows服务?
  • 是否需要在<ServiceInstall>标签中显式指定Account属性?

我尝试了以下方法,但均无效:

  • 通过Win+R运行gpedit.msc,在本地组策略编辑器中检查[计算机配置]→[Windows设置]→[安全设置]→[本地策略]→[安全选项]中的[用户账户控制:以管理员批准模式运行所有管理员]选项
  • 检查“Windows按钮>更改用户账户控制设置”
  • 确保使用mstsc /admin或对应平台的等效命令运行终端服务控制台
  • 重启目标机器
  • 安装ASP.NET Core Runtime 6.0

内容的提问来源于stack exchange,提问作者yellow_submarine

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 20:27:19