winhttpcertcfg -g -i "MyPfxcertificate.pfx" -c LOCAL_MACHINE\My -a “Network Service” -p pfxpassword
You may find more examples here and download the WinHttpCertCfg tool here.The only drawback that has this tool is that is intended for PFX certificate file format only and if you need to install a certificate public key only like a .p7b or .crt standard formats, you will need another tool like the Certificate Manager tool (CertMgr.exe) that comes with the Microsoft .NET Framework SDK tools and its usage is very simple as well.This example installs the MyCA root certificate to the Local Machine “Trusted Root Certification Authorities” store (Root).
certmgr -add -all -c "MyCA.p7b" -s -r localMachine Root
As you see, both tools comes in handy whenever you need to build a deployment script or just assign the required permissions the a certificate private key file without the hassle of complicated APIs or obscure directory paths like “[Documents and Settings]\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys” and the like.
This posting is provided "AS IS" with no warranties, and confers no rights.