'******************************************************************************\ ' CertLister.vbs lists all certificates and SubjectName fields in a specified ' CurrentUserStore and optionally, depending on the "certdialog" boolean value, ' displays a detailed certificate dialog which can be used for exporting public ' and private keys safely. ' ' On Win2000+, the defined store "names" for location "CurrentUserStore" are listed ' in the win32 registry as subkeys under: ' HKEY_CURRENT_USER\Software\Microsoft\SystemCertificates ' ' Requires the CAPICOM PSDK redistributable, and capicom.dll to be registered: ' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/security/capicom_start_page.asp ' ' Based on CAPICOM sample in MS PSDK at: ' c:\Program Files\Microsoft SDK\Samples\WinBase\Security\Crypto\CAPICOM\vbs ' M. Gallant 04/03/2002 ' ******************************************************************************/ Option Explicit Dim Store Dim Certificate Dim infotxt Dim storename, Message, Title '------ switch to display detailed cert dialog ----- Const certdialog = True '-- Some typical cert store names in CurrentUserStore location ---- Const mystore = "MY" Const friends = "AddressBook" Const trustroot = "ROOT" Const request = "REQUEST" Const castore = "CA" '-------------------------------------------------------- Message = "Enter a certificate store name:" Title = "CertLister - by M. Gallant" '--- Prompt to get certificate store Name --- storename = InputBox(Message, Title, "MY", 300, 300) ' Evaluate the user input. If storename = "" Then ' Canceled by the user so quit WScript.Quit End If infotxt = "-- Certificates in " & storename & " store: -----" & vbCrLf & vbCrLf Set Store = CreateObject("CAPICOM.Store") 'Store.Open 0, MY,0 Store.Open 2, storename ,0 'open currentuser location for read-only For Each Certificate In Store.Certificates If certdialog Then Certificate.Display infotxt = infotxt & Certificate.SubjectName & vbCrLf & vbCrLf Next Set Store = Nothing WScript.Echo infotxt '------ End CertLister script -------------------------