【发布时间】:2015-07-16 01:44:45
【问题描述】:
我想使用我的代码卸载软件,我已经尝试了 wmic 方法来执行卸载,但它无法在系统中找到我的软件。是否可以在不使用 msi 文件或任何安装文件的情况下进行卸载。我找到了这段代码,但它不起作用---
public string GetUninstallCommandFor(string productDisplayName)
{
RegistryKey localMachine = Registry.LocalMachine;
string productsRoot = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products";
RegistryKey products = localMachine.OpenSubKey(productsRoot);
string[] productFolders = products.GetSubKeyNames();
foreach (string p in productFolders)
{
RegistryKey installProperties = products.OpenSubKey(p + @"\InstallProperties");
if (installProperties != null)
{
string displayName = (string)installProperties.GetValue("DisplayName");
if ((displayName != null) && (displayName.Contains(productDisplayName)))
{
string uninstallCommand = (string)installProperties.GetValue("UninstallString");
return uninstallCommand;
}
}
}
return "";
}
【问题讨论】:
-
“但它不起作用”是一个无用的问题陈述。
-
所以你能建议我一个方法来做到这一点......
-
这看起来像是 stackoverflow.com/questions/334490/uninstall-without-msi-file 的副本。唯一可靠的方法是使用:“msiexec.exe /x {your-product-code-guid}”
-
我建议你用“它不起作用”来描述你的意思。
-
我使用 installshield 创建一个包并静默安装,现在我想静默卸载它,我的问题是,是否可以不使用 msi 文件或安装文件
标签: c# uninstallation