I create a console application (app.exe), with one line:
StreamWriter writer = File.CreateText(@"c:\file.txt");
Then, using caspol, I create a permissionset that states that the members of the permissionset cannot write to the c:\file.txt file, and apply it to a code group. This codegroup is then applied to the console application I just created.
Using mscorcfg.msc to evaluate the assembly, I made sure that app.exe is only affected by this new codegroup - and it is.
If I run this in Win7, with UAC at default - the app crashes, stating that the app didn't have the security permission to write to the file, which is what is to be expected.
However, if I run the app with UAC turned off - the app writes perfectly to the file. No crash, no warning, no nothing.
It's as if turning UAC off completes disables CAS. That can't possibly be right in any way, shape or form
Code Access Security and UAC
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

naura paxRank #2,843 · 502 reputationPosted Dec 11, 2009, 12:07 AM EST
Peter3 reputationPosted Dec 11, 2009, 4:09 AM EST
Kirtan PatelRank #292 · 8.6K reputationPosted Dec 11, 2009, 7:16 AM EST
If you want to Disable UAC Programatically i can do it but one Condition Restart required !!