Connecting a Smart Card to a Windows 7 virtual machine

The easiest way to connect a smart card to a virtual machine is to use remote desktop to connect to the virtual machine, and enable smart card sharing.  Since Windows Virtual PC uses remote desktop technology you get this out of the box.

However this can all fall apart if you are running Windows 7 inside the virtual machine.  The reason for this is that remote desktop requires that the remote server have the correct smart card drivers installed already, and Windows 7 did not include many smart card drivers by default.

The result is that if you try to use a smart card in a Windows 7 virtual machine (either under Windows Virtual PC or through remote desktop on Hyper-V) you are likely to get an error stating that the drivers are not present – like this:

smartcard1

Luckily – there are two ways that you can work around this.

The first way only works for Windows Virtual PC, and that is to just connect the smart card directly to the virtual machine, which will get Windows 7 to install the right drivers for you automatically.  Now – if you try to do this you may think it is not possible:

smartcard2

As you can see – my smart card is marked as “shared” and I cannot connect it to the virtual machine.  The reason for this is that the smart card is being shared with the virtual machine over remote desktop already.  To connect the smart card to the virtual machine all you need to do is disable integration mode:

smartcard3

Once you have attached the smart card to the virtual machine, and let Windows 7 load the drivers for the smart card, you can switch back to integrated mode and everything will work fine.

The other approach is to locate and load the drivers for your smart card manually (this will work with Windows Virtual PC or Hyper-V).  The first thing to do here is to open device manager on your computer and identify the type of smart card that you have (I have a Gemalto .NET Smart Card):

smartcard5

Then from inside the virtual machine you need to open a web browser and go to the Microsoft Update Catalog (https://test.catalog.update.microsoft.com/v7/site/DownloadInformation.aspx).  This site allows you to search for, and download, any driver that is offered over Microsoft Update:

smartcard7

When you have found your driver and downloaded it, all the files will be stored in a single .CAB file.  All you need to do is extract the files (double click on the .CAB file, select all the files inside and click Extract on the toolbar) then right click on the .INF file and select install:

smartcard12

And you are done.

With either approach you should be able to access the smart card inside of a Windows 7 virtual machine.

Cheers,
Ben