WIX - 权限不足卸载服务

问题描述 投票:0回答:2

我正在使用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.

这是显示的错误。

enter image description here

这是我的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 
c# service wix wix3
2个回答
0
投票

看起来它在卸载期间无法找到服务并查看您的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" />

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

ServiceControl


0
投票

您可以尝试指定您的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]'/>
© www.soinside.com 2019 - 2024. All rights reserved.