How do I get the actual file path in Vista using UAC?
I call CreateFile () to create a file in the Program Data directory. I am using SHGetSpecialFolderPath () to get the dir name.
I have a user on Vista for whom CreateFile () is returning error 5 (Access Denied). It would help if I knew where CreateFile () is actually trying to create the file so that we can check its folder permissions. The problem with Vista (UAC) is that it doesn't try to create a file in the directory I went through. It can also be in the VirtualStore directory. An additional source of confusion is that this user is German, and although SHGetSpecialFolderPath () returns "C: \ Program Data \ blah blah" as the path, I don't think this is actually the path. I think the German Vista uses the German word "Program Data". I would like to inform the user "This is the exact path where we are trying to create the file. Please check your permissions on this folder."
I know you can get the path from the open file descriptor, but in this case CreateFile () doesn't work, so I don't have an open handle. How can I get Vista to tell me the actual path where it is trying to create the file?
source to share
Start Process Monitor and see what it does: http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
source to share
If with UAC the paths used are not what you want, then the redirection is in effect. To make sure no redirection occurs, add a manifest to your application that tells Vista that your application is properly coded and aware of access restrictions (i.e. you don't write, for example, HKLM or the programs folder if your application doesn't need permissions administrator to run).
But your application should be able to write to the APPDATA folder (if that's what you're actually using).
Make sure you are using CSIDL_APPDATA and not CSIDL_COMMON_APPDATA (the latter is only available with admin rights).
To find the real path (the one you expect), tell the user to enter% APPDATA% in the explorer pane (or press Windows + R, then enter% APPDATA%, enter). This will open an explorer in that folder.
source to share
I understand that ProgramData is used by Vista to write files that it tried to write inside C: \ Program Files but failed because unless you are using the application as administrator you cannot write inside program files. You might want to try saving the files in the AppData folder under the current user.
source to share