【发布时间】:2016-01-03 17:31:49
【问题描述】:
我正在创建一个应用程序,我要求在安装过程中应用程序卸载一些其他已安装的程序,所以我首先要做的是创建一个控制台应用程序来卸载程序,直到有工作,我添加这个控制台应用程序作为设置和构建解决方案中的自定义操作,但在安装时卸载程序不起作用。
对不起我的英语不好:)。
我使用以下代码进行卸载。
string UninstallCommandString = "/x {0} /qn";
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
process.StartInfo = startInfo;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardError = true;
startInfo.FileName = "msiexec.exe";
startInfo.Arguments = string.Format(UninstallCommandString, "{CCB85747-267D-45C6-AC32-7979ADFCD2D8}");
process.Start();
process.WaitForExit();
string UninstallCommandString2 = "/x {0} /qn";
Process process2 = new Process();
ProcessStartInfo startInfo2 = new ProcessStartInfo();
process2.StartInfo = startInfo2;
startInfo2.UseShellExecute = false;
startInfo2.RedirectStandardError = true;
startInfo2.FileName = "msiexec.exe";
startInfo2.Arguments = string.Format(UninstallCommandString2, "{7A8A8C03-6BEA-45B4-BAD9-EBC5790A037A}");
process2.Start();
process2.WaitForExit();
string UninstallCommandString3 = "/x {0} /qn";
Process process3 = new Process();
ProcessStartInfo startInfo3 = new ProcessStartInfo();
process3.StartInfo = startInfo3;
startInfo3.UseShellExecute = false;
startInfo3.RedirectStandardError = true;
startInfo3.FileName = "msiexec.exe";
startInfo3.Arguments = string.Format(UninstallCommandString3, "{6AFDD6D0-3F33-45F0-B058-677F2080AE22}");
process3.Start();
process3.WaitForExit();
string UninstallCommandString4 = "/x {0} /qn";
Process process4 = new Process();
ProcessStartInfo startInfo4 = new ProcessStartInfo();
process4.StartInfo = startInfo4;
startInfo4.UseShellExecute = false;
startInfo4.RedirectStandardError = true;
startInfo4.FileName = "msiexec.exe";
startInfo4.Arguments = string.Format(UninstallCommandString4, "{ACC5E4C6-B4D2-4227-B577-95D511C05A6E}");
process4.Start();
process4.WaitForExit();
【问题讨论】:
标签: c# uninstallation setup-project windows-installer