Managing the Default Virtual Machine Location with Windows Virtual PC

Managing the Default Virtual Machine Location with Windows Virtual PC

  • Comments 4

Virtual PC 2004 / 2007 always default to creating new virtual machines in the current users “My Documents” folder.  Users who need to use an alternate location can do so by setting up the MYVIRTUALMACHINES environment variable.

Things have changed significantly with Windows Virtual PC.

The first change is that we no longer look at the MYVIRTUALMACHINES environment variable.

The second change is that we no longer enforce a static default location.  Rather – every time you create a new virtual machine – the location that you specify for the new virtual machine:


Will be used as the default virtual machine location the next time you try to create a virtual machine.

Finally – if you do want to programmatically set a default location you can do so using some simple scripts:


# Check for correct command-line arguments
If ($path -eq "")
 write-host "Missing command-line argument."
 write-host "USage: SetDefaultVMPath.ps1 -path `"Default path to use for new virtual machines`""
# Connect to Virtual PC
$vpc=new-object –com VirtualPC.Application –Strict
# Set the new default VM path
$vpc.DefaultVMConfigurationPath = $path


Option Explicit
Dim namedArguments, vpc, defaultVMPath
' Check that the script is running at the command line.
If UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" Then
 WScript.Echo "This script must be run under CScript."
End If
' Get the new default VM path from the command-line arguments
Set namedArguments = WScript.Arguments.Named
If namedArguments.Exists("path") Then
 defaultVMPath = namedArguments.Item("path")
 WScript.Echo "Missing command-line argument"
 WScript.Echo "Usage: SetDefaultVMPath.vbs /path:" & chr(34) & "Default path to use for new virtual machines" & chr(34)
End If
' Attempt to connect to Virtual PC
On Error Resume Next
Set vpc = CreateObject("VirtualPC.Application")
If Err.Number <> 0 Then
 WScript.Echo "Unable to connect to Virtual PC."
End if
On Error Goto 0
' Set the new default VM path
vpc.DefaultVMConfigurationPath = defaultVMPath



Note that while these scripts will set the default location – if the user chooses a different location when creating a new virtual machine, that location will become the new default virtual machine location. 

This means that these scripts are only really useful for customizing an initial deployment of Windows Virtual PC.  Alternatively you could run these scripts on logon to set the default path back to your desired location.


Leave a Comment
  • Please add 5 and 1 and type the answer here:
  • Post
  • What about the location for undo disks? Also why is My Virtual Machines not a special folder so its location can be changed in the registry? Lots of times my system drive has very little space left because of Virtual machine undo disks automatically going there.

  • Any suggestions for 2007 Virtual PC's that are on external harddrives?

    Depending upon what other drives are plugged in, my largest drive is sometimes e: sometimes f: etc.

    I also want to connect this external drive to other machine upon occasion and run the VPC there, so all virtual pc files need to be on the external, not on the host.  How can this be done?

  • You are somewhat incorrect as the static default location is still pointed to \My Documents\My Virtual Machines.

    To change this open the default location, Right Click in the area where you would see the Virtual Machines settings, open Properties, choose the Location tab, and modify your default location.

    Anything that was saved in the previous default location can be moved automatically. The system will prompt to do so.

  • Looking for script sample to set / define the "Default Virtual Machine".

    This var appears in other scripts as "default_vm".

    Any help much appreciated!

Page 1 of 1 (4 items)