I developed an auto-updater for my application that gets a MD5 hash list for all files from the update server and downloads the new files in case of a mismatch. At the moment, this only happens for the main DLL file, that is loaded at runtime after (!) the updater has finished his work.
It works perfectly in Windows XP but a few users already complained that the updater gives them Error 5 Access Denied when trying to overwrite said DLL file. If they run it with administrator privileges, it works, but it's an annoyance for them to always agree on admin privileges when starting the program.
My question: why is the access to overwrite that DLL denied, is there a way to make it happen without the UAC prompt?
Alternatively: is there a way to make the application run as administrat开发者_高级运维or permanently in a way that the user just has to agree to it once, and not every time it's run.
PS: I'm using Qt 4.7, especially the QFile::open method with QFile::WriteOnly | QFile::Truncate and call a QMessageBox if open fails with errorString() and some explanation.
Thanks!
Have you made sure that the application is "single-instance" i.e. never running twice ?
IF not this could be an explanation...
As for making the app run always as Administrator - you should NEVER do this...
EDIT:
As for Windows 7:
You are trying to overwrite something in the program directy... it is a security measure of the OS to prevent writing there without admin privilege...
these can help dealing with UAC:
http://msdn.microsoft.com/en-us/library/bb756929.aspx
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/20acb8b9-8b9c-4a85-9416-fccdef579f10/
Windows 7 and Vista UAC - Programmatically requesting elevation in C#
精彩评论