Home > database >  How do I make WPF app running as User, launch Updater prompting for escalated privileges, then have
How do I make WPF app running as User, launch Updater prompting for escalated privileges, then have

Time:03-28

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.

CodePudding user response:

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.

How to start a new process without administrator privileges from a process with administrator privileges?

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.

  • Related