简体   繁体   中英

WIX - Insufficient Privileges Uninstalling Service

I'm building an install package for a Windows Service using WIX installer. I'm can create the install package and it installs and starts the service with an issue but I'm unable to uninstall the service. The error in the uninstall log is is:

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.

followed by:

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.

which is the displayed error.

在此处输入图片说明

Here is the component configuration in my 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>

The account I log in to the machine with is in the machine's administrators group. What have I not set up correctly to get the uninstall to work?

EDIT: As requested, I ran the installer with verbose logging. Here are the command line's that I found in the logs.

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 

Looks like its not able to find the service during uninstall and looking at your WXS:

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

You are asking your installer to delete the service on both install and uninstall. Hence the installer cant find the service to be removed, can you please change that to and try again:

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

Remove - Specifies whether the service should be removed by the DeleteServices action on install, uninstall or both. For 'install', the service will be removed only when the parent component is being installed (msiInstallStateLocal or msiInstallStateSource); for 'uninstall', the service will be removed only when the parent component is being removed (msiInstallStateAbsent); for 'both', the service will be removed in both cases.

ServiceControl

You could try to specify your windows user account.

<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]'/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM