[英]uninstalling an application and then installing another one using c#
I'm trying to uninstall an application from the system and install a new version of it. 我正在尝试从系统中卸载应用程序并安装新版本。
I tried out using Process.start and WaitForExit method in c# code 我尝试在C#代码中使用Process.start和WaitForExit方法
var process1 = Process.Start(@"C:\Program Files\CPUID\CPU-Z\unins000.exe");
process1.WaitForExit();
var process2 = Process.Start(@"C:\Users\abc\Downloads\Programs\cpu-z_1.71-setup-en.exe");
When the code runs, the setup file for the cpu-z_1.71 launches before the uninstaller exit. 代码运行时,将在卸载程序退出之前启动cpu-z_1.71的安装文件。
How can i make the installer to wait until I press the OK button of the complete uninstallation dialog box. 如何使安装程序等待直到按下完整的卸载对话框的“确定”按钮。
Is it possible to do the above task using process or should I use some alternative 是否可以使用流程来完成上述任务,还是应该使用其他替代方法?
You can find a method from below articles. 您可以从以下文章中找到一种方法。
and this code can be a method. 并且此代码可以是一种方法。
private void RunNotePad()
{
Process p1 = new Process("notepad.exe");
p1.EnableRaisingEvents = true;
//when process exit, excute ProcessExited function.
p1.Exited += new EventHandler(ProcessExited);
p1.Start();
}
public void ProcessExited(object source, EventArgs e)
{
//start to install a new version
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.