简体   繁体   English

从已安装的应用程序c#获取GUID

[英]Get GUID from an installed Application c#

I am doing a winform application that need to uninstall another Winform application that is installed by installshield. 我正在做一个Winform应用程序,该应用程序需要卸载由installshield安装的另一个Winform应用程序。 I have searched the correct way to unistall it is 我搜索了取消安装的正确方法是

Process.Start("msiexec /x {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"); Process.Start(“ msiexec / x {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}”); where xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx represents GUID of that application that you want to uninstall. 其中xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx代表您要卸载的应用程序的GUID。

But I do not how can I find the GUID from an application called text.exe 但是我不知道如何从名为text.exe的应用程序中找到GUID

I have found 我已经发现

var assembly = typeof(Program).Assembly; var assembly = typeof(Program).Assembly; var attribute = (GuidAttribute)assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0]; var attribute =(GuidAttribute)assembly.GetCustomAttributes(typeof(GuidAttribute),true)[0]; var id = attribute.Value; var id = attribute.Value;

but this retrieves the GUID from the current Application. 但这将从当前应用程序检索GUID

Any ideas? 有任何想法吗?

That GUID is the GUID associated with the installer (more accurately known as a Package Code ), you'll be able to pull these from HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall, I am not familiar with the ability to pull this directly from the application. 该GUID是与安装程序关联的GUID(更准确地称为Package Code ),您将能够从HKLM \\ SOFTWARE \\ Microsoft \\ Windows \\ CurrentVersion \\ Uninstall中拉出它们,我不熟悉拉出此功能的能力直接从应用程序。

*Edit Alternatively if you have access to the WiX script (should you be using WiX to generate the MSI) it should be the Id attribute of the Product Element. *编辑或者,如果您有权访问WiX脚本(应该使用WiX生成MSI),则它应该是产品元素的ID属性。 You may also be able to use a tool such as Orca to check this property of an MSI that has already been created. 您也许还可以使用Orca之类的工具来检查已创建的MSI的此属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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