这个问题与以下内容完全相同:
如图所示,我检索了application.的uninstallstring
这是我试图使该应用程序卸载的代码。
uninstlString = Convert.ToString(subkey.GetValue("UninstallString"));
if (uninstlString.Contains("MsiExec.exe"))
{
//Console.WriteLine(uninstlString);
//Console.ReadLine();
string args = "/x{" + uninstlString.Split("/".ToCharArray())[1].Split("I{".ToCharArray())[2];
//string prdctId = uninstlString.Substring(12);
uninstallProcess.StartInfo.FileName = uninstlString.Split("/".ToCharArray())[0];
uninstallProcess.StartInfo.Arguments = args;
uninstallProcess.StartInfo.UseShellExecute = false;
uninstallProcess.Start();
uninstallProcess.WaitForExit();
}
但是在运行这段代码之后......它说索引超出了范围......有人可以帮我解决这些问题吗?
请在重复的问题中查看我的答案:Uninstalling program。
MSI API:使用MSI API正确地使用COM自动化进行卸载,而不是字符串操作。我不确定您的情况是什么,我们需要了解您的目标是什么。通常有其他方法可以使整个操作风险降低。
按产品名称卸载:如果您只知道要卸载的产品的名称,那么可以看看如何使用MSI API在此处卸载它:Is there an alternative to GUID when using msiexec to uninstall an application?
其他卸载方法:还有许多其他方法可以卸载:Uninstalling an MSI file from the command line without using msiexec。
一些链接: