Question

I'm using ShellExecute(NULL, L"open", szSomeDirectory, 0, 0, SW_SHOWDEFAULT) to open a directory in explorer.

I'm trying to open a directory that I would normally be prompted with You currently do not have permission to access this folder. and would give me option to get access and show a UAC prompt.

When I'm executing ShellExecute, Explorer gives me a error message saying Access Denied.

My program is running with administrator privileges but that doesn't seem to matter.

How can I get access to open this folder?

Was it helpful?

Solution

Figured it out.

My user account didn't have access to the file.

My solution was to use AccessCheck before ShellExecute to see if I could access the file, and if I couldn't, use SetNamedSecurityInfo to add an ACE for the logon user account with full access.

OTHER TIPS

you can set the UAC level in the linker manifest for your program.

Take a look at this: Strange file-permissions if apps run as administrator

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top