Wednesday, March 18, 2015

ErrorCode = 18 (There are no more files)

This is somewhat identity related, I promise.  Tried to use a VPN client lately with a virtual smart card; it had worked perfectly for a long time but now failed with “ErrorCode = 18 (There are no more files)”.  Thankful for the useful error message I began adding files to my computer but the problem persisted.

Coincidently I did create a new virtual smart card recently so wondered if the presence of two virtual smart cards was causing the problem.

There is good content on TechNet for virtual smart cards here: Virtual Smart Card Overview

That led me to TpmVscMgr.exe, a command-line tool for creating and deleting TPM virtual smart cards.  Pretty handy utility (TODO – find some nice APIs and write this thing as a PowerShell module).  The only trick to this utility is that it doesn’t list the virtual smart cards for you.

Listing the smart cards is kinda hacky but this worked for me:

### Get items from the registry

Get-ChildItem 'HKLM:\SYSTEM\CurrentControlSet\Control\DeviceClasses\{50dd5230-ba8a-11d1-bf5d-0000f805f530}' |

### Get just the DeviceInstance

Get-ItemProperty -Name DeviceInstance | Select DeviceInstance

Here is the output:

 

DeviceInstance                                                                                                                                                                                                    

--------------                                                                                                                                                                                                    

ROOT\SMARTCARDREADER\0001                                                                                                                                                                                         

USB\VID_076B&PID_3021\5&3d7770d&0&1                                                                                                                                                                               

 

 

 

Those values work as input to TpmVscMgr.exe.  In my case I had one too many, and chose to delete one of them (an educated guess). 

After running the command I was able to VPN.  Yeah!

No comments: