Preventing Virtual PC’s obsession with “My Virtual Machines”

System Requirements:

  • Virtual PC 2004, SP1

The Problem:

Virtual PC 2004 ritually insists upon creating the a “My Virtual Machines” directory beneath your user profiles My Documents root, even if you have previously deleted this folder and frequently set the ‘working’ path to another location while in the file browser.

If you wish to store your VMC and VHD data elsewhere on your system or network, you must manually specify the full path to the Virtual PC Console each time you make configuration changes, as well as delete a new instance of My Virtual Machines.

The Fix:

This seems like a simple, yet typically Microsoft omission from the program – utterly defeating the idea of it being “My” Documents in favour of whatever Microsoft, Adobe, BVRP etc want to make it.
Most applications store working path information in the registry’s Current User settings, Virtual PC has, however been hard coded with its user profile paths, making non of the traditional registry keys beneath the Current User Software hive.

There is, however a way around this limitation, as presented cryptically in the readme.htm; which states:

MYVIRTUALMACHINES environment variable controls the default location where new Virtual Machine Configuration (.vmc) files are created
By default, Virtual PC creates the virtual machine configuration files (.vmc) in My Documents\My Virtual Machines. Virtual PC then stores other files that are used by the virtual machine in the same folder as the .vmc file. This is controlled on the host operating system by the MYVIRTUALMACINES environment variable. You can change the MYVIRTUALMACHINES environment variable to a different location. For more information on how to change environment variables, consult the documentation included with the version of Windows on which you have installed Virtual PC 2004.

What this is saying, in case you’re don’t happen to have a MCSE, is that as a counter measure, Virtual PC will screen for the presence of a Shell Wide configuration pointer (Environment Variable) defined as MYVIRTUALMACHINES.
Ever seen, for example, “%SYSTEMROOT%” or “%TEMP%” pop up before in Windows? They are environment variables specifying where the Windows folder (Q:\Windows\) and global Temp folder (N:\Eccentric\Folder\Naming\Temp\) are.

The Environment Variables are considered constants, and not likely to change – if indeed they will ever change. Administrative privileges are required to set or unset an environment variable, lacking the susceptibility of the registry. As they are global, they will already be considered active no matter who is logged into the system (unlike with Current User Registry settings) and unlike with Local Machine Registry settings, are globally available to anything looking for %MYVIRTUALMACHINES%. Saving the system or VPC drivers from specifying access to reams of registry hive to get to the desired few bytes of information.

There are two ways to set an environment variable.

Using the GUI:

  1. Pull up the Control Panel
  2. Run the System Applet
  3. Open the Advanced Tab
  4. Choose Environment Variables…
  5. Under System Variables click New…
  6. In the Variable Name enter:
  7. Under Variable Value enter the Full System Path to your new MVM root e.g.
    D:\Virtual PC\Images\

Exit and restart Virtual PC for the change to become active under Virtual PC.

Using the Registry:

  1. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
  2. Create a new String value named:
  3. Set the value to equal the Full System Path to your new MVM root e.g.
    D:\Virtual PC\Images\

If you set the variable by hand in this fashion, you may need to log off before the change is recognised by the system.

Once you have added the system environment variable, Virtual PC will stop creating the My Virtual Machines folder beneath My Documents, and will default file system browser windows to the new MYVIRTUALMACHINES path.