My application has a built-in self update system via another app called "updater.exe" which is in the same folder with the main application to update. It downloads the newest version, terminates the old one (if it's running) and then overwrites it.
The problem is, to do that the updater.exe must be run with the Administrator privileges in order to have access to C:Program FilesMyApp
So far so good, the main app runs the updater.exe with Admin privileges (using UAC) but then the problem appears:
After update is completed, I want the new installed version to start automatically. Guess what? Of course the main app runs with the Admin privileges also. The scenerio is simple:
Main app[running as user] --> Updater App[run as admin] --> Main app[ADMIN again]
Just because my application uses My.Settings
object, it loses all the stored settings when it run as admin because typically it always start as normal user and as you may know, My.Settings
is user-sensivite
object.
How can I fix such an issue? I've searched around but could not find anything related to "Run as normal user" but always running as admin, which is quite easy.
Well, honestly, in the other hand, I don't think such a thing could be possible because the updater app cannot know which specific user has started it. Or can it? Is there something I'm missing here ?
If I am right, it is the only option to NOT to use My.Settings but the Windows Registry to store user preferences?
Thanks by now.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…