Oct 202009

One of the great things about using VirtualPC in software development and testing is that the VirtualPC “virtual machine” really only has one hardware configuration.  The virtual machine defines a virtual hard disk, virtual display, virtual network, and even its own virtual BIOS for booting up the virtual machine.

The downside to that uniformity is that the VM can’t access any kind of hardware on your real PC that is beyond what VirtualPC already knows about.  Sure, you can install device drivers in the VM, but those device drivers won’t be able to find their hardware because it doesn’t exist in the virtual machine.

For example, how do you plug a USB flash drive into your virtual machine?  Or how do you use your SmartCard reader to perform a secure login from your virtual machine?  You can’t.  At least, not using the VirtualPC terminal.

I stumbled into this sand trap when I was setting up a new VM and needed to pull source files from version control onto the VM.  The version control server (TFS) is on the private corporate network, but I’m not.  I normally access corpnet via a Virtual Private Network (VPN), which requires use of a SecureCard (encryption keys stored on your corporate photo ID badge) to log in.

One solution would be to pull the sources to my local hard disk across the VPN, then share those files using a network share so that the VM can see them. That would work if the VM only needed read-only access to the files, but since I would also be making changes to the source files inside the VM and from my local machine at the same time (multiple irons in the fire), sharing one copy of the source code wouldn’t work.

I could copy the source tree from the local drive into the VM’s local drive, but that just makes it harder to check in changes made to the files in the VM.

The ideal would be to configure the VM to connect to corpnet via VPN and pull the sources directly from version control.  Changes made to the sources in the VM could be checked in and managed independently of the source files on my local machine. But the VPN client requires access to the SmartCard reader to complete the VPN login, and the VM doesn’t have access to the SmartCard reader hardware.

Or does it?  Turns out, there is a way to do it.  Instead of using the VirtualPC terminal, use Remote Desktop to connect to the virtual machine.

Remote Desktop’s terminal window supports transporting certain kinds of device information from your local machine to the remote machine.  This allows you to print from an app on the remote machine and have it print on your local printer, for example, or access files on a USB drive plugged into the local machine.  The Remote Desktop client also supports sharing SmartCard reader access across the Remote Desktop connection.

Here’s how to set it up:

First you need to configure your VM to accept Remote Desktop connections.  Fire up the VM in the VirtualPC terminal, click on Start in the Windows task bar, right-click on My Computer, click on Advanced System Settings, and select the Remote tab.  Under Remote Desktop, select one of the two Allow settings depending on your needs, then click on Select Users and use the next dialog to add user accounts that can access that machine remotely.  Accounts with administrator privileges automatically have remote access once Remote Desktop access is allowed.

Make sure your virtual machine is set up for network access.  If the VM isn’t on the network, you can’t connect to it with Remote Desktop.  If you can open a browser in your VM and browse web sites, you’re good to go.

Make sure your virtual machine has a computer name.  You’ll be connecting to it by name (IP address also works, but less friendly), so make sure you know what its name is.  You can find (and change) the computer name on the My Computer properties page.  Make sure it is different from your local computer name.

Minimize the VirtualPC terminal window on your local desktop.  Launch Remote Desktop and type in the virtual machine’s computer name.  Click on Options to configure Remote Desktop.

Remote Desktop Login

Local device sharing is turned off by default in Remote Desktop. Click on the Local Resources tab, then on the More button near the bottom of the dialog:

Local Devices and Resources

This will bring up the Local Devices and Resources selection dialog where you can select which local drives and devices to make available to the remote machine:

Select local devices and resources

Check the Smart Cards checkbox to enable sharing your local SmartCard reader with the remote machine, then close the dialogs and click Connect on the original Remote Desktop dialog.

You should be prompted to log into the remote machine (log in with a user name and password on the virtual machine, not the local machine) and voila – you’re looking at your virtual machine through Remote Desktop’s eyes!

From here I can fire up my VPN client, connect the VM to corpnet using the SmartCard reader, and access the TFS server to manage source files in the VM directly.

Remote Desktop can share local printers, local disk drives and drive letter mapped network shares, serial ports, and SecureCard readers to the remote machine. It can also share some types of Plug N Play media devices such as digital cameras (to access image files on the camera via USB perhaps).  USB devices that don’t behave as a file device or as a printer probably won’t be shareable across the Remote Desktop connection. A USB webcam, for example, cannot be shared across a Remote Desktop connection.

Remote Desktop is by far my preferred client for working with VirtualPC VMs.  RD’s mouse, keyboard, and clipboard integration between the remote and local desktop is more seamless than the VirtualPC terminal and RD just feels snappier overall.

Sorry, the comment form is closed at this time.