Two applications; WPF Application and Console Updater. WPF is launched by User checks to see if there is an Update to be performed, launches Updater with escalation prompt so that it can replace WPF Application(and supporting files). After Updater replaces files want it to start the WPF Application as the original User. In case anyone wants to know I had to escalate privileges on Updater because it was replacing files under Program Files folder where the WPF Application is installed.
1 Answers
Launch the updater program as administrator using the Process class. This will present the UAC and the user can decide if they will allow the updater to run. You can then exit your original program. At the end of your update, do the same thing without administrator privileges to launch your software again.
I don't like any of these answers, but they will work. It would be better to deploy your updates using regular windows installer techniques (Wix, or one of the many other packages), and as part of that process, have it restart the original program after upgrading it. This is the approach you see in most software. You're going to need to write an installer to get the software on the computer anyway, just add a step at the end to start the software.

- 1,286
- 9
- 15
-
How do I prompt for non-administrator privileges? Is it a different verb on the ProcessStartInfo? – Jim Mar 27 '22 at 03:21
-
https://stackoverflow.com/questions/11169431/how-to-start-a-new-process-without-administrator-privileges-from-a-process-with – John V Mar 27 '22 at 03:53
-
1I had a problem on the re-launch in the update check logic. Once, I made the fix to that code the following worked as far as launching as a normal user from the administrator level Updater.. ProcessStartInfo processStartInfo = new ProcessStartInfo("
"); processStartInfo.WindowStyle = ProcessWindowStyle.Normal; processStartInfo.WorkingDirectory = " – Jim Mar 27 '22 at 23:06"; processStartInfo.UseShellExecute = false; processStartInfo.CreateNoWindow = false; Process.Start(processStartInfo); Thank you for the responses.