How to find GUID of Wix Burn executable for programmatically uninstall?

那年仲夏 提交于 2019-12-07 12:18:12

问题


I've created wix bootstrapper project. While installing it creates registry key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{SOME_GUID}

So I can uninstall it using ARP.But I'd like to uninstall it programmatically.To do this I need the value of {SOME_GUID} to search the key in registry for UninstallString value. However it's impossible to get this information from my project, because Bundle element does not have attributes to set this GUID.


I found out that this GUID is equal to Bundle's ProviderKey GUID, but only if ProviderKey is assigned automatically. When I try to change ProviderKey using bundle "ProviderKey" attribute this two GUIDs are not equal anymore.


回答1:


Each time that you compile your bootstrapper project, it is assigned a new identity—a GUID called BundleId that you cannot change. In this respect, every bundle that you create is unique. The UpgradeCode attribute allows us to link two bootstrappers, making them related bundles. This relationship allows one bundle to detect and upgrade the installed packages of the other.




回答2:


If you just want to obtain the "current" bundle's ID then you can read it from BootstrapperApplicationData.xml at runtime. Not sure if there are better ways to do that.


However, if your problem is that multiple instances of the same version (different build) of the bootstrapper are being installed side by side then read on...

I had a similar problem: since every time you compile the bootstrapper your bundle has a new ID, that meant if I try to install it again it was installing another instance of the bundle (with the new ID) and then I had 2 instances of my bundle in ARP. (Really don't know what the use case for this is..)

I don't want 2 instances of the bundle, especially if they are identical versions. The only solution I found was to use one of the bootstrapper's events PlanRelatedBundle to remove any "related" bundles:

private void BootstrapperOnPlanRelatedBundle(object sender, PlanRelatedBundleEventArgs e)
{
    e.State = RequestState.Absent;
}

Note: I'm not sure if this is the best way to go about this, but considering the poor documentation it's the best I've found.



来源:https://stackoverflow.com/questions/26675457/how-to-find-guid-of-wix-burn-executable-for-programmatically-uninstall

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!