通过注册表卸载程序(unistallstring) [英] Uninstalling programs by registry (unistallstring)

查看:118
本文介绍了通过注册表卸载程序(unistallstring)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用我的代码卸载软件,我的代码正在使用unistallStringmsiexec.exe / x {your-product-code-guid}和C:\Program Files \TeamViewer \ uninstall .exe \。



但现在正在处理uninstallString,例如C:\Program Files \Common Files \ Adob​​e AIR \Versions \\\\ 0 \\ _Resources \Adobe AIR Updater.exe -arp:uninstall..



这个抛出异常(系统找不到指定的文件)



(这里S = MyUnistallString)



我尝试了什么:



I want to uninstall a software by using my code, my code is working on unistallString "msiexec.exe /x {your-product-code-guid}" and "C:\Program Files\TeamViewer\uninstall.exe\".

but now working on uninstallString like "C:\Program Files\Common Files\Adobe AIR\Versions\1.0\Resources\Adobe AIR Updater.exe -arp:uninstall"..

this throwing exception ("The system cannot find the file specified")

(Here S= MyUnistallString)

What I have tried:

<pre> try
        {
            s = s.Replace("\"", ""); //Replace <">

            string uninstallArguments = null;
            string uninstallAssembly = null;
            if (!s.Contains("/"))
            {
                uninstallAssembly = s;
            }

            else
            {
                string[] uninstallArgumentsArray = s.Split(new string[] { " /" }, StringSplitOptions.RemoveEmptyEntries); // Split for any parameters
                if (uninstallArgumentsArray.Count() > 1)
                {
                    for (int count = 1; count < uninstallArgumentsArray.Count(); count++)
                    {
                        uninstallArguments = "/" + uninstallArgumentsArray[count];
                    }
                }
                uninstallAssembly = uninstallArgumentsArray[0];
            }


            if (!string.IsNullOrWhiteSpace(uninstallAssembly))
            {
                Process uninstallProcess = new Process();
                uninstallProcess.StartInfo = new ProcessStartInfo();
                uninstallProcess.StartInfo.FileName = uninstallAssembly;
                uninstallProcess.StartInfo.Arguments = uninstallArguments;
                uninstallProcess.Start();

            }
        }
        catch (Exception)
        {

        }

推荐答案

我想在你的
s.Split(new string[] { " /" }

您还需要考虑其他字符,例如

you also need to consider other characters like

" -"


这篇关于通过注册表卸载程序(unistallstring)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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