I'm writing a software and trying to implement an automatic updater into it as a separate application. I have both the software itself and the updater under the same solution.
When an update is available from a server, my program prompts the user to update, this part works.
I fail to call the updater app and then exit only the first program.
This is what I have not:
private void button2_Click(object sender, EventArgs e)
{
// Update
ExecuteAsAdmin("AutoUpdater.exe");
//System.Windows.Forms.Application.Exit();
Process.GetCurrentProcess().Kill();
}
public void ExecuteAsAdmin(string fileName)
{
Process proc = new Process();
proc.StartInfo.FileName = fileName;
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.Verb = "runas";
proc.Start();
}
This does successfully start the AutoUpdater.exe but then exists both, the first program and the AutoUpdater.exe, latter should not be exited as that should do the updating.
How to exit only one program from the same solution?