问题描述
我正在尝试自动卸载使用WiX创建的软件包,以更改已安装的软件堆栈&无需重新配置整个操作系统即可进行配置.最终,我将使用powershell脚本执行此操作,但此刻,我似乎无法让我的测试包与cmd交互地进行卸载.
I'm trying to automate the uninstallation of packages created using WiX for the purposes of changing the installed software stack & configuration without reprovisioning a whole OS. Eventually I'll use powershell scripting to do this but at the moment I can't seem to get my test package to uninstall interactively with cmd.
如果我跑步:
msiexec /x '{A4BFF20C-A21E-4720-88E5-79D5A5AEB2E8}'
msiexec /x A4BFF20C-A21E-4720-88E5-79D5A5AEB2E8
我得到:
无法打开安装软件包.请验证该软件包存在,您可以访问它,或与应用程序供应商联系验证这是一个有效的Windows Installer程序包."
"The installation package could not be opened. Verify that the packageexists and that you can access it, or contact the application vendorto verify that this is a valid Windows Installer Package."
如果我运行:msiexec /x {A4BFF20C-A21E-4720-88E5-79D5A5AEB2E8}
我得到:
此操作仅对当前安装的产品有效"
我查看了 Windows安装程序指南, WiX文档,msiexec文档和使用orca来查看.我自己是位女士,但我还没有真正找到能清楚说明卸载处理方式的任何信息. .msi文件是否为必需文件,如果不是,那么为什么Windows安装程序在给定GUID时会认为是该文件?
I've looked at the windows installer guide, the WiX documentation, msiexec documentation and used orca to go over the .msi myself but I've not really found anything that gives a clear picture of how an uninstall is processed. Is the .msi file required and if not then why does windows installer seem to think it is when given a GUID?
.msi安装程序的WiX代码为:
The WiX code for the .msi installer is:
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='htp://schemas.microsoft.com/wix/2006/wi' >
<!--DO NOT COPY / PASTE THE PRODUCT ID GUID BELOW TO YOUR OWN WIX SOURCE -->
<Product Id='A4BFF20C-A21E-4720-88E5-79D5A5AEB2E8' Language='2057'
Manufacturer='COMPANYNAME IT-Operations'
Name='COMPANYNAMEServerListener' Version='1.0.0'
UpgradeCode='PUT-GUID-HERE'>
<Package Id='*' Manufacturer='COMPANYNAME IT-Operations' Compressed='yes' />
<Media Id='1' Cabinet='COMPANYNAMEServerListener.cab' EmbedCab='yes' />
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='COMPANYNAME' Name='COMPANYNAME'>
<Directory Id='INSTALLDIR' Name='COMPANYNAMEServerListener'>
<Component Id='MainExecutable' Guid='*' >
<File Id='COMPANYNAMEServerListener.exe'
Source='COMPANYNAMEServerListener.exe' Vital='yes'
KeyPath='yes' />
<ServiceInstall
Id='COMPANYNAMEServerListenerInstall'
DisplayName='COMPANYNAMEServerListener'
Description='Accepts and discards TCP connections on port 28028 to indicate that this server is alive and ready to be controlled'
Name='COMPANYNAMEServerListener'
Account='NT AUTHORITY\LocalService'
ErrorControl='normal'
Start='auto'
Type='ownProcess'
Vital='yes'
>
<ServiceDependency Id='tcpip'/>
</ServiceInstall>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="COMPANYNAMEServerListener" Wait="yes" />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
<Feature Id='Complete' Level='1' >
<ComponentRef Id='MainExecutable' />
</Feature>
<CustomTable Id ="COMPANYNAMEMetadata">
<Column Id="Property" Type="string" Category="Identifier" PrimaryKey="yes"/>
<Column Id="Value" Type="string"/>
<Row>
<Data Column="Property">InstallString</Data>
<Data Column="Value">/qn</Data>
</Row>
</CustomTable>
</Product>
</Wix>
推荐答案
感谢所有帮助-事实证明这是WiX问题.
Thanks all for the help - turns out it was a WiX issue.
当产品ID GUID保留为显式&时,按照问题进行硬编码,当使用orca检查时,生成的.msi不具有ProductCode属性,而具有Product ID属性.
When the Product ID GUID was left explicit & hardcoded as in the question, the resulting .msi had no ProductCode property but a Product ID property instead when inspected with orca.
一旦我将GUID更改为"*"以自动生成,就会显示ProductCode,并且在其他答案确认的语法下都可以正常工作.
Once I changed the GUID to '*' to auto-generate, the ProductCode showed up and all works fine with syntax confirmed by the other answers.
这篇关于如何在不存在.msi文件的情况下使用产品ID guid使用msiexec进行卸载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!