1

I am working on a windows based c++ application. I have created the installer for this project using Visual Studio 2012. This project also has some configuration files, which are copied intothe installation folder(c:\program files\). When the application starts, one log file is also created in this installation directory. Now the problem is when I install the application on a windows 7 system, which has admin rights, everything works fine. But, when I install this on a system, which does not have admin rights, that neither my application is able to read the config file present in the current directory, nor the log file gets generated.

How can I set/change the permission of this installation directory during the instllation, so that I can modify/read the config file and also log file gets created.

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
SGP
  • 83
  • 10

1 Answers1

1

You need to decide if you want your application to have administrator privileges or not, because only an app with administrator privileges can modify/read the config file and create log file in a sub-directory of "Program Files".

If you are OK with this, then create an app that will open an UAC prompt when it is started, which request administrator privileges. To do this, open project property pages and go to "Linker->Manifest File", then set the value of "UAC execution level" to requireAdministrator. On the other hand, if you consider this to be an overkill, I suggest you change your app to create a directory in user folder. This folder will be used to store config file and log file. The most common approach is to create a folder in C:\Users\some_user\AppData\Local.

Please note that I would suggest the latter approach, there is no need to give an app administrator privileges just to keep config and log file in "Program Files". However, I am not familiar enough with your application, maybe an UAC prompt is a better solution. That is up to you to decide.

Marko Popovic
  • 3,999
  • 3
  • 22
  • 37
  • Can you suggest me how I can give UAC prompt at application start up? – SGP Jan 15 '16 at 11:51
  • @SGP Did you manage to solve your problem using the info in this answer? If you did, please consider upvoting it and/or marking it as accepted. – Marko Popovic Jan 16 '16 at 11:33