Friday, August 28, 2009

Windows Virtual PC Hacking

I recently was able to upgrade my work laptop to Windows 7 RTM and have been quite happy with the experience so far. Everything seems to be running very quickly and I like a lot of the subtle improvements that have been made to the UI.

I did, however, hit a small snag with Virtual PC. You can install Virtual PC 2007 on Windows 7, but there are some known issues and your mileage may vary. I need to be able to run a 32-bit guest OS in order to use our VPN software because it currently only supports 32-bit OS’s. When I was running Vista x64, I just used Virtual PC 2007 without issues. It was a little clunky to have to run a VM in order to remote into work, but it worked.

So I installed Windows Virtual PC (currently a Release Candidate). The first interesting (and confusing) thing to note is that the ‘management’ application is no longer present. When you use the Start menu to open ‘Virtual Machines’, it just takes you to the ‘C:\Users\{username}\Virtual Machines’ folder. But if you look closely to the action area of the window, you’ll notice command like ‘Create Virtual Machine’. The management interface is built into the explorer shell for this folder!

So I just copied my VPC’s (both the .vmc & .vhd files) into the folder and double-clicked one of the VMC files and…

No luck. Despite others claiming that all they had to do was double-click their .vmc files, I just got an error message stating that it couldn’t find the .vhd file. I double-checked the path to the .vhd file in the .vmc file, but it was correct.

I then figured I would create a new VM and see what happens. Turns out that Windows Virtual PC creates a new type of file that has a .vmcx extension and places it into this folder (the .vhd files get created in the ‘C:\Users\{username}\AppData\Local\Microsoft\Windows Virtual PC\Virtual Machines’ folder by default). When i opened this up in my favorite text editor, it turns out that it is a simple XML file that points to the .vhd & .vmc files. After some quick editing, I was able to boot my VM’s as normal. Here is a sample .vmcx file:


<?xml version="1.0" encoding="UTF-16"?>
<!-- Microsoft Virtual Machine Description and Registration Settings -->
<vm_description>
<ram_size type="string">384 MB</ram_size>
<vmstate type="string">Powered down</vmstate>
<primary_disk1 type="string">C:\Users\{Username}\Virtual Machines\{VPC Folder}\{VPC HD}.vhd</primary_disk1>
<secondary_disk1 type="string">D</secondary_disk1>
<notes type="string" />
<vmc_path type="string">C:\Users\{Username}\Virtual Machines\{VPC Folder}\{VPC Configuration}.vmc</vmc_path>
</vm_description>



UPDATE: After sleeping on this for the night, I realized that the ‘Create Virtual Machine’ wizard had a section in it that allowed you to select an existing .vhd file. This is the same functionality that has always existed, but I was so focused on what was different earlier, that I forgot about that option. If you take this (faster and easier route), you will have your old VM’s up and running in no time. Be aware though, that it will create a new .vmc file to use the existing .vhd files. If you want, just edit the newly created .vmcx file and have it point to the old .vmc file (removing the newly created one in the process).



Happy VM-ing!  :)