Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I create a directory without Administrator Rights / Privileges?

I am creating a DLL that goes with a 3rd-party program. Whether or not the 3rd-party program has Administrator rights in Windows is outside my control.

The DLL needs to create a directory, but it seems like CreateDirectory won't work because it doesn't have administrator rights.

Escalating the UAC isn't an option because I am only modifying the DLL, not the 3rd-party program. I can't force the user to right-click the 3rd-party program and "Run As Administrator".

(Visual C++ 2010)

EDIT

I am trying to write to C:\ProgramData\. I retrieve that path using SHGetFolderPath() and CSIDL_COMMON_APPDATA.

like image 773
paperduck Avatar asked Oct 23 '25 19:10

paperduck


1 Answers

Use CSIDL_APPDATA as the root folder for any user-specific directories/files, otherwise use CSIDL_COMMON_APPDATA instead. Either way, create your own subfolder under the chosen root for your app/DLL, as the root folder itself is protected from being written to. Typically, an installer should create your subfolder with adequate rights, and then the app/DLL can access it as needed.

like image 103
Remy Lebeau Avatar answered Oct 26 '25 08:10

Remy Lebeau