Sample code for 30+ languages & platforms
VBScript

Import a Certificate (.cer file) into a Windows Certificate Store

See more Certificates Examples

Demonstrates how to import a certificate (without private key) into a Windows certificate store.

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.LoadFromFile("qa_data/certs/example.cer")
If (success = 0) Then
    outFile.WriteLine(cert.LastErrorText)
    WScript.Quit
End If

set certStoreCU = CreateObject("Chilkat.CertStore")
readOnlyFlag = 0

' "CurrentUser" and "My" are the exact keywords to select your user account's certificate store.
success = certStoreCU.OpenWindowsStore("CurrentUser","My",readOnlyFlag)
If (success = 0) Then
    outFile.WriteLine("Failed to open the CurrentUser/My certificate store for read/write.")
    WScript.Quit
End If

' Import the certificate into the CurrentUser/My certificate store.
success = certStoreCU.AddCertificate(cert)
If (success = 0) Then
    outFile.WriteLine(certStoreCU.LastErrorText)
    WScript.Quit
End If

outFile.WriteLine("Imported " & cert.SubjectCN)
outFile.WriteLine("Success.")

outFile.Close