Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My program is a WPF app which is installed into Program Files (x86) folder, in this app I have a method called every 30 minutes to compared version of current app and version of .msi file in local folder. If version of .msi file is the lastest, app will run this .msi file to update version using the below code:
C#
Process installerProcess = new Process();
ProcessStartInfo processInfo = new ProcessStartInfo();
processInfo.FileName = "msiexec";
processInfo.Arguments = $@"/i  {msiFilePath}  /q";
processInfo.Verb = "runas";
installerProcess.StartInfo = processInfo;
installerProcess.Start();
installerProcess.WaitForExit();

After updating I want to restart this app by using this code:
C#
Process.Start(Process.GetCurrentProcess().MainModule.FileName);
Environment.Exit(0);

It is my problem: After updating version, my windows also restart and app doesn't auto launch when restarting finished

What I have tried:

I add log after called installerProcess.WaitForExit(); to notify app is updated successfully but in the log file I don't see any message. It's seem to windows restart before log is wrote.

What I want: my app can update the latest version if exists and auto launch after update

Could anyone help me this problem?
Posted
Updated 3-Jan-23 21:29pm

1 solution

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