Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
<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)
        {

        }
Posted
Updated 19-Jul-17 3:01am
Comments
BillWoodruff 19-Jul-17 16:13pm    
You may wish to ask this on the Adobe Air developer forum:

https://forums.adobe.com/community/air/development/overview

1 solution

I think in your
C#
s.Split(new string[] { " /" }
you also need to consider other characters like
C#
" -"
 
Share this answer
 
Comments
S M Fasih ALi 19-Jul-17 9:26am    
Thanks buddy :) It Works

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900