我为Ingo / MongoDb的自定义安装编写了一个In / Uninstaller。
我的安装mongoDB的方法如下。
private Process GetInstallMongoProcess() {
Log("Installing MongoDB Version 3.4.10 ...");
Process installProcess = new Process();
installProcess.StartInfo = new ProcessStartInfo("msiexec.exe", $@"/q /Lie {Constants.LogFileName} /i mongodb-win32-x86_64-2008plus-ssl-3.4.10-signed.msi INSTALLLOCATION=""{Constants.Path}3.4\"" ADDLOCAL=""all""");
installProcess.OutputDataReceived += OnInstallProcessDataReceived;
installProcess.Start();
return installProcess;
}
但是随后我需要检查此应用程序是否已安装。我的方式是
private bool CheckIfAlreadyInstalled()
{
string[] registryKeys = { @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" };
bool appIsInstalled = false;
foreach (string registryKey in registryKeys) {
RegistryKey key = Registry.LocalMachine.OpenSubKey(registryKey);
if (key != null) {
List<string> listOfInstalledApplications = key.GetSubKeyNames().ToList();
appIsInstalled = listOfInstalledApplications.Contains(ApplicationGuid);
}
}
if (appIsInstalled) {
Log("MongoDB is already installed");
}
return appIsInstalled;
}
我找不到已安装的应用程序。名称或ApplicationGuid都没有。
我大约有300个条目,但是我所需的条目不存在,但是可以在Regedit.exe中看到已安装的软件
我在错误的节点中搜索吗?