WIX-特权不足,无法卸载服务

时间:2019-02-11 17:26:15

标签: c# service wix wix3

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

2 个答案:

答案 0 :(得分: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操作删除服务。对于“安装”,仅在安装父组件(msiInstallStateLocal或msiInstallStateSource)时,才会删除该服务。对于“卸载”,仅在删除父组件时才删除该服务(msiInstallStateAbsent);对于“两者”,两种情况下都将删除该服务。

ServiceControl

答案 1 :(得分: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]'/>