I'm sure you would have heard of the awesome virtualization features in Windows 7. It’s pretty simple to setup a new virtual machine. In this article, we will look at few ways to work with virtual floppy images in Windows Virtual PC(WVPC).

Everyone loves APIs

If you're a developer, here's the treat. And the relevant powershell snippet:

$vmName = "SampleVM"                       # name of the virtual machine
$floppyImagePath = "D:\FloppyImage.vfd"    # full path to the virtual floppy image
$vpc = new-object -com VirtualPC.Application
$vm = $vpc.FindVirtualMachine($vmName)
foreach ($floppyDrive in $vm.FloppyDrives)
{
    $retVal = $floppyDrive.AttachImage($floppyImagePath)
}

Modify the variables and run the snippet in powershell.

And the config files ..

By default, WVPC stores your virtual machines at %SystemDrive%\Users\<Username>\Virtual Machines. If you look in there, each virtual machine is simply a xml file. E.g. The contents of SampleVM.vmcx would be:

1 <?xml version="1.0" encoding="UTF-16"?>
2 <!-- Microsoft Virtual Machine Description and Registration Settings -->
3 <vm_description>
4         <ram_size type="string">512 MB</ram_size>
5         <vmstate type="string">Powered down</vmstate>
6         <primary_disk1 type="string">C:\Users\armahapa\AppData\Local\Microsoft\Windows Virtual PC\Virtual Machines\SampleVM.vhd</primary_disk1>
7         <secondary_disk1 type="string">O</secondary_disk1>
8         <notes type="string" />
9         <vmc_path type="string">C:\Users\armahapa\AppData\Local\Microsoft\Windows Virtual PC\Virtual Machines\SampleVM.vmc</vmc_path>
10 </vm_description>

Let's go one level deep and explore the VMC file(refer vmc_path in the snippet above):

67                 <standard>
68                         <name type="string">Virtual PC 7</name>
69                         <version type="string">0001.0000.0000</version>
70                 </standard>
71                 <super_io>
72                         <floppy id="0">
73                                 <pathname>
74                                         <absolute type="string" />
75                                         <relative type="string" />
76                                 </pathname>
77                         </floppy>
78                         <parallel_port>
79                                 <port_type type="integer">0</port_type>
80                         </parallel_port>
81                         <serial_port>
82                                 <connect_immediately type="boolean">false</connect_immediately>
83                         </serial_port>
84                         <serial_port id="0">
85                                 <port_type type="integer">0</port_type>
86                         </serial_port>
87                         <serial_port id="1">
88                                 <port_type type="integer">0</port_type>
89                         </serial_port>
90                 </super_io>
91         </hardware>
92         <integration>

The configuration file already has the floppy node, simply modify it to add a custom floppy image(underlined below):

67                 <standard>
68                         <name type="string">Virtual PC 7</name>
69                         <version type="string">0001.0000.0000</version>
70                 </standard>
71                 <super_io>
72                         <floppy id="0">
73                                 <pathname>
74                                         <absolute type="string">D:\FloppyImage.vfd</absolute>
75                                         <relative type="string" />
76                                 </pathname>
77                         </floppy>
78                         <parallel_port>
79                                 <port_type type="integer">0</port_type>
80                         </parallel_port>
81                         <serial_port>
82                                 <connect_immediately type="boolean">false</connect_immediately>
83                         </serial_port>
84                         <serial_port id="0">
85                                 <port_type type="integer">0</port_type>
86                         </serial_port>
87                         <serial_port id="1">
88                                 <port_type type="integer">0</port_type>
89                         </serial_port>
90                 </super_io>
91         </hardware>
92         <integration>

Save the VMC file and start using the floppy image.

Happy VM’ing :-)

Edit: Replaced images with text. Thanks Abhinaba for the suggestion :)