我知道以前曾经问过,但请耐心等待。我有一个实用程序,它读取注册表中的Unistall位置,然后将结果与需要删除的应用程序列表进行比较。 80%的时间可以使用,但诀窍是要删除的项目之一是防病毒(因此可以用AVG安装替换)。对于很多公司而言,这不起作用。以下是我如何获取已安装软件的摘录:
const string Win32Loc = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
//const string Win32Loc = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\USerData\S-1-5-18";
const string Win64Loc = @"Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
List<Application> apps = new List<Application>();
string location = bool64BitOs ? Win64Loc : Win32Loc;
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(location))
{
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
apps.Add(new Application { DisplayName = sk.GetValue("DisplayName") == null ? "" : (string)sk.GetValue("DisplayName"), AppKey = skName });
}
}
}
当写入文本文件时,结果如下所示:
名称PowerDVD密钥InstallShield_ {6811CAA0-BF12-11D4-9EA1-0050BAE317E1}
名称ESC主页插件密钥InstallShield_ {E738A392-F690-4A9D-808E-7BAF80E0B398}
名称Intuit SiteBuilder Key Intuit SiteBuilder
名称Microsoft Visual J#2.0可再发行组件包密钥Microsoft Visual J#2.0可再发行组件包
命名Norton AntiVirus Key NAV
命名Windows Live Essentials密钥WinLiveSuite
命名Microsoft Visual C ++ 2008 ATL更新kb973924 - x86 9.0.30729.4148密钥{002D9D5E-29BA-3E6D-9BC4-3D7D6DBC735C
所以你会看到有些安装有密钥,有些却没有。这意味着80%的工作具有MSIEXEC呼叫的密钥,而其他工作则失败。我正在使用Installer / UserData / UserXXXXX / Products,但我不知道如何遍历所有用户。在我提供的转储中,诺顿需要去,但我看不出怎么做。
非常感谢任何帮助。
答案 0 :(得分:2)
我同意selbie关于使用“UninstallString”的评论(虽然有时你也不会这样,但是对于MSI的使用,可以获得GUID并使用msiexec /x {GUID}
)。
尽管如此,我不建议通过此方法卸载Norton A / V产品。因为他们的卸载程序是废话并经常留下应该删除的许多软件,Symantec提供了一个实际安全地完成工作的工具:Norton Removal Tool。强烈推荐!