MsiExec.exe 产品 ID 卸载 [英] MsiExec.exe product id uninstall

查看:75
本文介绍了MsiExec.exe 产品 ID 卸载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如图所示,我检索到了一个应用程序的卸载字符串.

As shown in the picture I've retrieved the uninstallstring of an application.

这是我试图卸载该应用程序的代码.

And this is the code which I'm trying to make that application uninstall.

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();
}

但是在运行这段代码之后……它说索引超出了范围……有人可以帮我写代码吗?

But after running this code...it says it the index is out of range... Can someone help me with the code?

推荐答案

请在重复问题中查看我的回答:正在卸载程序.

<小时>

MSI API:不要使用字符串操作,而是正确使用 MSI API 来使用 COM 自动化进行卸载.我不确定你的场景是什么,我们需要更多地了解你的目标是什么.通常有其他方法可以降低整个操作的风险.


MSI API: Rather than string manipulation, use the MSI API properly to uninstall using COM automation. I am not sure what your scenario is, we would need to know more about what your goal is. Very often there are alternative ways to do things that make the whole operation less risky.

按产品名称卸载:如果您只知道要卸载的产品的名称,那么不妨看看如何使用 MSI API 来卸载在这里卸载它:使用 msiexec 卸载应用程序时是否有替代 GUID 的方法?

其他卸载方法:还有无数其他卸载方法:不使用 msiexec 从命令行卸载 MSI 文件.

一些链接:

  • WIX (remove all previous versions) (uninstall by upgrade code, or product code)
  • Wix: Get Directory from File Path (find correct product by product name string scan)

这篇关于MsiExec.exe 产品 ID 卸载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆