【问题标题】:WIX - Insufficient Privileges Uninstalling ServiceWIX - 权限不足卸载服务
【发布时间】:2019-02-11 17:26:14
【问题描述】:

我正在使用 WIX 安装程序为 Windows 服务构建安装包。我可以创建安装包,它会安装并启动有问题的服务,但我无法卸载该服务。卸载日志中的错误是:

MSI (s) (E4:E4) [11:51:15:117]: Error: 1060. Failed to change configuration of service Service Name because handle to the service could be obtained. Check if the service exists on the system.

接着是:

MSI (s) (E4:E4) [11:51:18:900]: Product: Service Name -- Error 1939. Service '' (Service Name) could not be configured.  This could be a problem with the package or your permissions. Verify that you have sufficient privileges to configure system services.

这是显示的错误。

这是我的 Product.wxs 中的组件配置。

<Component Id="$(var.TestImportService.TargetFileName)" Guid="7BCCB287-D4A5-42B9-B83B-E67E22D56D90">        
        <File Id="$(var.TestImportService.TargetFileName)" Name="$(var.TestImportService.TargetFileName)" Source="$(var.TestImportService.TargetPath)" KeyPath="yes" />
        <!-- Remove all files from the INSTALLFOLDER on uninstall -->
        <RemoveFile Id="ALLFILES" Name="*.*" On="uninstall" />
        <!-- Tell WiX to install the Service -->
        <ServiceInstall Id="ServiceInstaller"
                        Name="$(var.Name)"
                        Type="ownProcess"
                        DisplayName="$(var.Name)"
                        Description="The description."
                        Interactive="no"
                        Arguments="-start"
                        Vital="yes"
                        Start="auto"
                        ErrorControl="normal">
          <util:PermissionEx User="LocalSystem"
                             GenericAll="yes"
                             ServiceChangeConfig="yes"
                             ServiceEnumerateDependents="yes"
                             ChangePermission="yes"
                             ServiceInterrogate="yes"
                             ServicePauseContinue="yes"
                             ServiceQueryConfig="yes"
                             ServiceQueryStatus="yes"
                             ServiceStart="yes"
                             ServiceStop="yes" />
        </ServiceInstall>
        <!-- Tell WiX to start the Service -->
        <ServiceControl Id="ServiceInstaller" Name="$(var.Name)" Start="install" Stop="both" Remove="both" />
        <ServiceConfig ServiceName="$(var.Name)" DelayedAutoStart="1" PreShutdownDelay="5000" OnInstall="yes" OnReinstall="yes" OnUninstall="yes" />
      </Component>

我登录机器的帐户在机器的管理员组中。我没有正确设置什么来使卸载正常工作?

编辑: 根据要求,我使用详细日志记录运行安装程序。这是我在日志中找到的命令行。

From Install Log
MSI (c) (48:44) [13:44:13:945]: Command Line: CURRENTDIRECTORY=C:\Users\user.name\Documents\Visual Studio Projects\TestService\TestServiceSetup\bin\Debug CLIENTUILEVEL=0 CLIENTPROCESSID=14664 

...

MSI (s) (DC:4C) [13:44:45:191]: Command Line: INSTALLFOLDER=C:\Program Files (x86)\Company Name\Test Service\ ROOTDIRECTORY=C:\Program Files (x86)\Company Name\ TARGETDIR=C:\ CURRENTDIRECTORY=C:\Users\user.name\Documents\Visual Studio Projects\TestService\TestServiceSetup\bin\Debug CLIENTUILEVEL=0 CLIENTPROCESSID=14664 USERNAME=Information Technology COMPANYNAME=Company Name SOURCEDIR=C:\Users\user.name\Documents\Visual Studio Projects\TestService\TestServiceSetup\bin\Debug\ ACTION=INSTALL EXECUTEACTION=INSTALL ROOTDRIVE=C:\ INSTALLLEVEL=1 SECONDSEQUENCE=1 ADDLOCAL=MainApplication ACTION=INSTALL 


From Uninstall Log
MSI (s) (9C:F4) [13:55:40:179]: Command Line: REMOVE=ALL CURRENTDIRECTORY=C:\Users\user.name\Documents\Visual Studio Projects\TestService\TestServiceSetup\bin\Debug CLIENTUILEVEL=2 CLIENTPROCESSID=5000 

【问题讨论】:

  • 服务在安装前是否存在于 services.msc 中?出错时?这可能有助于指出权限错误或编码错误。
  • 是的,服务安装正确,在服务控制面板中显示并运行,只是因为权限错误无法卸载。

标签: c# service wix wix3


【解决方案1】:

在卸载和查看您的 WXS 期间似乎无法找到该服务:

<ServiceControl Id="ServiceInstaller" Name="$(var.Name)" Start="install" Stop="both" Remove="both" />

您要求安装程序在安装和卸载时删除该服务。因此安装程序找不到要删除的服务,请您将其更改为并重试:

<ServiceControl Id="ServiceInstaller" Name="$(var.Name)" Start="install" Stop="both" Remove="uninstall" />

Remove - 指定是否应在安装、卸载或同时通过 DeleteServices 操作删除服务。对于“安装”,只有在安装父组件时才会删除该服务(msiInstallStateLocal 或 msiInstallStateSource);对于“卸载”,只有在删除父组件时才会删除服务(msiInstallStateAbsent);对于“both”,在这两种情况下都将删除该服务。

ServiceControl

【讨论】:

  • 感谢@Isaiah4110,我将 Remove="both" 更改为 "Remove="uninstall",但当我尝试卸载服务时仍然出现相同的错误。
  • 您能否从您的安装/卸载日志中提供更多详细信息?使用 /l*v MyLogFile.txt 运行 msiexe。我需要有关 wix 运行的实际命令行以安装和卸载服务的详细信息。
【解决方案2】:

您可以尝试指定您的 windows 用户帐户。

<u:User Id="UpdateUserLogonAsService" UpdateIfExists="yes" CreateUser="no" Name="[USERNAME]" LogonAsService="yes" RemoveOnUninstall="no"/>
                <ServiceInstall 
                      Id="ServiceInstaller" 
                      Name="$(var.Name)"
                      Type="ownProcess"
                      DisplayName="$(var.Name)"
                      Description="The description."
                      Start="auto"
                      ErrorControl="normal"
                      Account='[USERNAME]'
                      Password='[PASSWORD]'/>

【讨论】:

    猜你喜欢
    • 2019-01-17
    • 1970-01-01
    • 2011-05-31
    • 1970-01-01
    • 2013-03-20
    • 2022-10-18
    • 1970-01-01
    • 1970-01-01
    • 2018-10-28
    相关资源
    最近更新 更多