Sample code for 30+ languages & platforms
VBScript

Windows Certificate Stores - Find Certificate by Common Name

See more Certificates Examples

Searches the Windows certificate stores for a certificate that matches the specified common name (CN).

Note: This example requires Chilkat v10.0.0 or greater.

Chilkat VBScript Downloads

VBScript
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)

success = 0

set cert = CreateObject("Chilkat.Cert")
success = cert.LoadByCommonName("Chilkat Software, Inc.")
If (success = 0) Then
    outFile.WriteLine(cert.LastErrorText)
    WScript.Quit
End If

outFile.WriteLine(cert.SubjectDN)
outFile.WriteLine("Success.")

outFile.Close