Delete Registry Key

Glenn Maxwell 10,146 Reputation points
2021-06-12T19:08:57.763+00:00

Hi Experts

I have an application which was not properly uninstalled on few servers. To install an upgraded version of this application i need to delete the below registry keys of previous versions residing in HKEY_CLASSES_ROOT\Installer\Products

HKEY_CLASSES_ROOT\Installer\Products\11111111111111111111
HKEY_CLASSES_ROOT\Installer\Products\22222222222222222222
HKEY_CLASSES_ROOT\Installer\Products\22222222222222222222

How do i delete this registry keys using PowerShell. For example i have the folder 11111111111111111111 under Products.
i want to delete this folder 11111111111111111111 and all subfolders inside it. experts help me with the syntax.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,363 questions
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 31,571 Reputation points
    2021-06-12T20:01:52.787+00:00

    Powershell doesn't limit you to just using cmdlet's, it can also run executables. Use reg.exe. It's simple.

    reg.exe delete HKEY_CLASSES_ROOT\Installer\Products\11111111111111111111 /f
    

    The cmdlet version:

    Remove-Item Registry::HKEY_CLASSES_ROOT\Installer\Products\11111111111111111111 -Recurse  -Force  
    
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Rich Matheisen 44,776 Reputation points
    2021-06-12T19:38:38.287+00:00

    Try this:

    Remove-Item HKLM:\Installer\Products\11111111111111111111
    
    0 comments No comments

  2. Andreas Baumgarten 96,361 Reputation points MVP
    2021-06-12T19:43:25.94+00:00

    Hi @Glenn Maxwell ,

    HKEY_CLASSES_ROOT is a merge of HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER keys.
    https://learn.microsoft.com/en-us/windows/win32/sysinfo/hkey-classes-root-key?redirectedfrom=MSDN

    Check HKLM and HKCU for the registry key you want to delete.

    This should help to get started with the PowerShell script
    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/remove-itemproperty?view=powershell-7.1#example-3--remove-a-registry-value-by-using-the-pipeline

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    0 comments No comments

  3. Falcon IT Services 286 Reputation points
    2021-06-12T22:02:36.047+00:00

    Hello,

    You can also try using Revo uninstaller, it will remove registry keys associated with programs that have been corrupted or partially installed/uninstalled.

    -Miguel
    http://www.falconitservices.com

    0 comments No comments