Retired Microsoft Blog disclaimer

This directory is a mirror of retired "Windows PKI Team" TechNet blog and is provided as is. All posting authorship and copyrights belong to respective authors.
Original URL:
Post name: How to manually set the archive flag for certifictes
Original author: MS2065 [MSFT]
Posting date: 2007-02-22T11:19:00+00:00

If you have to select a certain certificate for authentication for example, you may wonder why several certificates are presented by the UI. Internet Explorer may offer several client authentication certificates while securely connecting to a web site or Outlook presents a number of certificates that can be used for eMail encryption.

One reason for such behavior could be that unnecessarily multiple certificates are available in your certificate store. Multiple certificates for the same purpose can exist if old certificates are not properly archived when new certificates are enrolled. Autoenrollment takes care of the archival process but when certificates are manually enrolled, old certificates are not flagged as archived.

Instead of deleting certificates (what you should never do with encryption certificates) you can just archive them. Unfortunately, the Certificates MMC snap-in provides no way to set the archive flag for a certificate. Therefore, install and use CAPICOM to set the flag for a given certificate with a script. The following script can be used as a sample to archive certificates. CAPICOM is fully documented on

Option Explicit


Dim oArgs
Dim oStore, oCertificates

Set oArgs = Wscript.Arguments
if oArgs.Count <> 1 then
 wscript.echo "Must specify the certificate thumbprint as argument"
 wscript.quit 1
end if

Set oStore = CreateObject("CAPICOM.Store")


Set oCertificates = oStore.Certificates.Find(CAPICOM_CERTIFICATE_FIND_SHA1_HASH, oArgs(0))

if oCertificates.Count = 1 then
 oCertificates(1).Archived = false
end if


Set oCertificates = Nothing
Set oStore = Nothing

The script requires the thumbprint of the certificate to be archived as command-line parameter, for example

cscript archivecert.vbs “be 46 c0 95 ea 4f b7”

To un-archive existing certificates, just change the line oCertificates(1).Archive=false to oCertificates(1).Archive=true.

To archive a certificate, use Notepad to create a text file Archive.inf that has the following content:

19 = Empty

To remove the archive bit from a certificate, use Notepad to create an INF file that has the following content:

19 =

Then run the following command at a command line for each cert to be archived:

certutil –repairstore –user my [CertificateThumbprint] Archive.inf

In the above command, you can also use a comma-separated list of CertificateThumbprints, if you prefer. If you copy/paste the thumbprint and it includes space characters, the thumbprint must be included in double quotes.

Once a certificate is flagged as archived, it does not appear in the certificates MMC snap-in unless the Archived certificates option is set. Also the certificate selection dialogs in Internet Explorer and Outlook do not show archived certificates.

To show archived certificates with the certificates MMC snap-in do the following:

1. Open the certificates MMC snap-in

2. Select the Certificates – Current User container in the left pane

3. From the menu chose View and then Options

4. Mark the option Archived certificates and click OK.

Share this article:


Comments are closed.