Question

I have a 'legacy' XP application which writes files in the [ProgramFiles]\[Application] folder, and writes registry keys in the HKLM\Software\[Application] path. When running the application in Windows Vista or Windows 7, the files and registry entries are written in the Virtual Store instead. That's fine; it doesn't break anything, yet.

Now, we've re-written the application in .NET. It only reads and writes files in "safe," user-scoped locations, and we use an application manifest with requestedExecutionLevel specified, in order to disable registry virtualization.

When users upgrade to the latest version, we would like to maintain compatibility with our old application, by importing settings from the previously-virtualized files and registry settings.

So, the question: Is there a way to access the files and registry keys in the Virtual Store from an application that has requestedExecutionLevel specified in its manifest?

Was it helpful?

Solution

I supposed I've left this question open long enough. Here are my findings.

There does not appear to be any way to access both the Virtual Store and the 'real' registry and file-system from the same process. The Virtual Store is applied automatically to Windows applications which do not specify the requestedExecutionLevel, and which are not launched "As Admin."

The answer, then, appears to be a specialized "migration" application. This application will not specify the requestedExecutionLevel, thereby guaranteeing that the application will be placed into the "Virtual Store," when launched without administrative privileges. The application operates in 2-stages:

  1. Launch the application without administrative access. The application will read the desired registry keys and file-system files from the Virtual Store, and save them in some temporary (non-virtualized) location like the user's AppData directory.
  2. Re-launch the application with administrative access. The application could actually do this for itself, automatically, to streamline the process. The application will now have access to the "real" registry and file system. The application will save the registry keys and files which backed-up from the Virtual Store, saving them to the desired 'real' location.

This application would ideally be somewhat generic, accepting any user-specified registry keys and files as input arguments during launch.

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