unable to delete a cert through command line RRS feed

  • Question

  • Hi,

    I need to delete a certificate located in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\CA\Certificates" via command line.

    I created a 'test' key under 'Certificates'.

    I typed the following command: REG DELETE /y "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\CA\Certificates\TEST", but I get an error msg 'Invalid key name'.

    One of my co-workers advised me to use this instead: %SYSTEMROOT%\system32\REG DELETE /y "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\CA\Certificates\TEST", but I get the same error.

    Please tell what I'm doing wrong.


    Jorge Ramos

    • Moved by Jesse Jiang Tuesday, March 8, 2011 6:18 AM (From:Visual C++ Language)
    Friday, March 4, 2011 6:56 PM

All replies

  • How are you creating the test key.

    If you're running on Vista or above you will need to run the REG command from an elevated command prompt because of registry virtualization.

    So first start the command prompt with elevated privileges by right clicking on the icon and selecting "Run as administrator".

    Then try running the REG DELETE command from it.

    Microsoft MVP (Visual C++)
    Saturday, March 5, 2011 3:51 AM
  • Thanks for replying. I created the 'test' key by right-clicking on certificates and created a new key.

    The O/S is XP. I'm already an admin on this machine so I didn't think I needed to 'run as' admin. The problem is that I have to do everything from command (reason being, I need to created a batch file to delete a few certs on some remote systems and I wont be able to use remote desktop or any other remote assistance tool. I have to push the batch and then push a command to run the command within the batch). How do I created a command to delete the cert with a 'run as' included within the command?


    Jorge Ramos

    Monday, March 7, 2011 9:20 PM

    Hi Jorge,


    I think your issue should be raised in the Security for Applications in Microsoft Windows Forum. I believe they will know more information of this issue than us, and I will move this one to that forum.


    Thanks for your understanding,


    Best regards,


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, March 8, 2011 6:18 AM
  • Thanks Jesse. I appreciate you looking into it. Look forward to hearing back from the  Security for Applications in Microsoft Windows Forum.


    Jorge Ramos

    Tuesday, March 8, 2011 5:39 PM
  • Hi,

    I was able to delete the 'test' certificate by using the following command:

    REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\CA\Certificates\TEST" /f

    Thanks for your assistance.



    Wednesday, March 9, 2011 3:54 PM