question

GlennMaxwell-2309 avatar image
0 Votes"
GlennMaxwell-2309 asked AndreasBaumgarten edited

Delete Registry Key

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MotoX80 avatar image
0 Votes"
MotoX80 answered

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  


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

Try this:

 Remove-Item HKLM:\Installer\Products\11111111111111111111


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered AndreasBaumgarten edited

Hi @GlennMaxwell-2309 ,

HKEY_CLASSES_ROOT is a merge of HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER keys.
https://docs.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://docs.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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

falconitservices avatar image
0 Votes"
falconitservices answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.