c# uninstall vsto file

private void uninstallVSTO()
        {
            try
            {
                string VSTOFilePath = System.IO.Path.Combine(GlobalVariables.xlWorkbook.Path, GlobalVariables.vstoName);
                if (System.IO.File.Exists(VSTOFilePath))
                {
                    Process VSTORun = new Process();
                    ProcessStartInfo Startinfo = new ProcessStartInfo();

                    Startinfo.FileName = Environment.GetEnvironmentVariable("commonprogramfiles") + @"\microsoft shared\VSTO\10.0\VSTOInstaller.exe";
                    Startinfo.Arguments = " /s /u " + " \"" + VSTOFilePath + "\"";
                    Startinfo.CreateNoWindow = true;
                    Startinfo.UseShellExecute = false;

                    VSTORun.StartInfo = Startinfo;
                    VSTORun.Start();
                    while (!VSTORun.HasExited)
                    {

                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }

Comments