0

I am working on a legacy MFC app that reads files from a set directory in Program Files but the .exe itself has to work from mostly anywhere else (including outside Program Files).

Is there any way to copy/download a file directly into Program Files without asking admin rights from the user? I am required that I do not ask for admin rights.

The MFC functions UrlDownloadToFile and CopyFile fail to save/copy a file directly into a Program Files folder when the application is ran without admin rights, although they run just fine if the app is run as admin.

One option could probably be specifying the path that the app should launch in, different from the actual .exe path, but I am not sure if that would help or how to do that.

  • 1
    Non, you can't write into the Program Files folder unless your process is elevated. – Jabberwocky Nov 10 '20 at 14:47
  • 2
    If you cannot change the location where files are written to, have the installer set an appropriate ACL on the destination directory. – IInspectable Nov 10 '20 at 15:23
  • Thanks, I will try this method soon and come back if I can make it work. – Trăistaru Vlad Nov 10 '20 at 18:07
  • There is one thing you can do, if you plan to update your software with an install utility. You can use that utility, which itself runs with elevated rights, to change the access rights of the folder where you store your data. – Michaël Roy Nov 11 '20 at 06:39

0 Answers0