【发布时间】: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 中?出错时?这可能有助于指出权限错误或编码错误。
-
是的,服务安装正确,在服务控制面板中显示并运行,只是因为权限错误无法卸载。