-2

How to get the list of protected from write folders with UAC enabled? The process that needs this information is launched with admin rights (installer).

lightstep
  • 765
  • 2
  • 8
  • 19
  • you won't go far wrong by assuming it's "loose in the root of C:" (ie, not in some folder under C:) and "everything under ProgramFiles" - whose exact location depends on your install. And probably the Windows folder too. Are you asking because you want your code to do something different? Better to try non elevated, then catch AccessDenied and do something in that case. – Kate Gregory Jun 16 '11 at 17:25

2 Answers2

8

UAC does not protect folders. UAC strips the administrator SID from a user's access token reducing him to a regular restricted ("normal") user. Applications can request elevation via manifests - then the entire process runs with the admin token.

If folders are not writeable with UAC enabled that means that NTFS security is set so that normal users cannot write but administrators can. As a remedy either change the permissions on those folders or run your application elevated (or redesign it so it writes to locations normal users have access to).

If you mean UAC virtualization (redirection of write attempts from system areas into the user profile): here is a good description of the feature from which I have copied the following:

  • Virtualization is only enabled for:
    • 32 bit interactive processes
    • Administrator writeable file/folder and registry keys
  • Virtualization is disabled for:
    • 64 bit processes
    • Non-interactive processes
    • Processes that impersonate
    • Kernel mode callers
    • Executables that have a requestedExecutionLevel
Helge Klein
  • 8,829
  • 8
  • 51
  • 71
1

As far as I know, there is no API way to do it. To do it manually you would have to try to write to each folder and see if you get any exceptions. To further complicate the issue, you may trigger file virtualization in which case you'll be able to write, but it goes to a different location.

Joel Lucsy
  • 8,520
  • 1
  • 29
  • 35