Reputation: 21
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:
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:
Process.Start(Process.GetCurrentProcess().MainModule.FileName);
Environment.Exit(0);
It is my problem from now: After updating version, my windows also restart and app doesn't auto launch when restarting finished
What I 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 lastest version if exists and auto launch after update
Could anyone help me this problem?
Upvotes: 1
Views: 67