Directory/Files Not Virtualized with UAC ON on Windows 7 RRS feed

  • Question

  • Hi,

    We have an application developed in C#/VS2005. It installs to c:\program files\<ourinstalldir>. When the application starts, it tries to create a subdirectory under <ourinstalldir> if it does not exist. On Windows 7 w/ UAC ON, the new directory goes to the virtual store \Users\<user>\AppData\Local\VirtualStore\Program Files\<ourinstalldir> as expected.

    The program was recompiled with VS2008 (target framework set to 2.0), the same code that creates the directory now throws an UnauthorizedAccessException exception (all previous app data/dirs in the virtual store was removed before re-installing). Nothing is written to the virtual store, I don't see any UAC events in the event viewer. Security settings on the install dir and installed binaries are the same.

    I'm completely stumped. Any ideas?




    Thursday, May 20, 2010 10:29 PM


  • With VS2008 it adds a manifest to the application to make them Vista/7 compatable so virtual store gets disabled. So one solution is to make sure the manifest doesn't get added.

    The better solution is to fix the underlying problem. Virtual store isn't guaranteed to last very long. It was added to Vista to ease the transition for legacy applications but it is only meant as a short term solution. You should actually get your application to place per user files in their profile or even figure out how the security functions in Windows work and give standard users write access to just your application directory.

    Fixing the problem, in my opinion, is better than relying on a feature which may not be in the next version of Windows.

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
    Visit my (not very good) blog at
    Thursday, May 20, 2010 10:41 PM