Windows 7 UAC prevents my app to write log data
-
Windows 7 UAC prevents my application to write log data in the installation folder. The original text log file exists from the very beggining, but its empty. When I start my app with the -L parameter to start logging, it does not write anything due the UAC control. If I rum my app with Admin Priviledges then it works. As you can understand I can not suggest my client to run the app with right click and "run as an Administrator". Is there any solution for that ? Best Regards,
sdancer75
-
Windows 7 UAC prevents my application to write log data in the installation folder. The original text log file exists from the very beggining, but its empty. When I start my app with the -L parameter to start logging, it does not write anything due the UAC control. If I rum my app with Admin Priviledges then it works. As you can understand I can not suggest my client to run the app with right click and "run as an Administrator". Is there any solution for that ? Best Regards,
sdancer75
Yes - don't try to write files in the installation folder. Your application will not have permission to do so. Instead, create a folder for your application under one of the AppData locations - CSIDL_APPDATA, CSIDL_LOCAL_APPDATA or CSIDL_COMMON_APPDATA - and write the log files to that folder. CSIDL (Windows)[^] SHGetFolderPath function (Windows)[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Yes - don't try to write files in the installation folder. Your application will not have permission to do so. Instead, create a folder for your application under one of the AppData locations - CSIDL_APPDATA, CSIDL_LOCAL_APPDATA or CSIDL_COMMON_APPDATA - and write the log files to that folder. CSIDL (Windows)[^] SHGetFolderPath function (Windows)[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Thank you Is that backward compatible with windows xp/vista ? I think that win Xp does not support AppData. Is that correct ? What to do in this case ? Check the os and take a path decision specifically for it ?
sdancer75
It should be supported in XP - the folder was called "Application Data" / "Local Data" back then. They changed it to "AppData\Roaming" and "AppData\Local" in Vista to reduce the chances of code breaking the 260-character path limit. Similarly, the "Documents and Settings" folder was renamed to "Users".
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
It should be supported in XP - the folder was called "Application Data" / "Local Data" back then. They changed it to "AppData\Roaming" and "AppData\Local" in Vista to reduce the chances of code breaking the 260-character path limit. Similarly, the "Documents and Settings" folder was renamed to "Users".
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer