Script to Delete registry entry based on Product name

Hi Experts,

I need help with creating a script that will delete a registry entry based on entry name. Reason, we are having issues installing adobe flash through SCCM. Researching the issue, we found that rouge entries of Adobe 11 under HKEY_CLASSES_ROOT\Installer\Products is the cause, if we delete those entries and then deploy the latest version it works perfect.

The problem is that under HKEY_CLASSES_ROOT\Installer\Products\ the next key varies based on the version of Adobe flash. So Adobe
(HKEY_CLASSES_ROOT\Installer\Products\A180D90768E45F34D976E6FA74EE85E5) could be version 11.0.0.226 and then it changes based on older and newer versions of 11.

Instead of manually going through half of our organization, is there a script that will run and delete entries under HKEY_CLASSES_ROOT\Installer\Products with the name "Adobe Flash Player 11 " as that is listed as product name under the key.

Thanks in Advance for you help.
jaya31Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KimputerCommented:
This VBscript should do the work. Please note, it must be run at the highest admin privelege (not just as admin login, also elevated cmd pronpt)

' Constants (taken from WinReg.h)
'
Const HKEY_CLASSES_ROOT   = &H80000000
Const HKEY_CURRENT_USER   = &H80000001
Const HKEY_LOCAL_MACHINE  = &H80000002
Const HKEY_USERS          = &H80000003

Const REG_SZ        = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY    = 3
Const REG_DWORD     = 4
Const REG_MULTI_SZ  = 7

' Chose computer name, registry tree and key path
'
strComputer = "." ' Use . for current machine
hDefKey = HKEY_CLASSES_ROOT
strKeyPath = "Installer\Products"

' Connect to registry provider on target machine with current user
'
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

' Enum the subkeys of the key path we've chosen
'
oReg.EnumKey hDefKey, strKeyPath, arrSubKeys

For Each strSubkey In arrSubKeys
  strSubKeyPath = strKeyPath & "\" & strSubkey
  
  oReg.EnumValues hDefKey, strSubKeyPath, arrValueNames, arrTypes

	 For i = LBound(arrValueNames) To UBound(arrValueNames)
		
	   strValueName = arrValueNames(i)
	   
			if arrTypes(i) = REG_SZ then
						oReg.GetStringValue hDefKey, strSubKeyPath, strValueName, strValue
						if ((strValueName = "ProductName") and (strValue = "Adobe Flash Player 11")) then
							msgbox "going to delete " & strSubKeyPath
							'Set objShell = Wscript.CreateObject("Wscript.Shell")
							DeleteSubkeys HKEY_CLASSES_ROOT, strSubKeyPath
						end if
			end if
	 Next

Next

Sub DeleteSubkeys(HKEY_CURRENT_USER, strKeyPath) 
    oReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubkeys 

    If IsArray(arrSubkeys) Then 
        For Each strSubkey In arrSubkeys 
            DeleteSubkeys HKEY_CURRENT_USER, strKeyPath & "\" & strSubkey 
        Next 
    End If 

    oReg.DeleteKey HKEY_CURRENT_USER, strKeyPath 
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jaya31Author Commented:
Hi Kimputer,

I tried to saved the script, renamed it vbs and vbsx and ran it through elevated cmd prompt and it doesn't deleted the key. Below is the exported registry key that points to what I want deleted, as mentioned, after under HCR\installer\products  that A180d... name changes based on versions. I'm not a scripting guy, maybe I left something out that is needed to delete or not running properly. Thanks again.


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Installer\Products\A180D90768E45F34D976E6FA74EE85E5]
"Clients"=hex(7):3a,00,00,00,00,00
"ProductName"="Adobe Flash Player 11 Plugin"
"PackageCode"="3DC1AC4F71080D64793DEC84CDAAB1F0"
"Language"=dword:00000409
"Version"=dword:0b040192
"Assignment"=dword:00000001
"AdvertiseFlags"=dword:00000000
"ProductIcon"="C:\\Windows\\Installer\\{709D081A-4E86-43F5-9D67-6EAF47EE585E}\\ARPPRODUCTICON.exe"
"InstanceType"=dword:00000000
"AuthorizedLUAApp"=dword:00000000
"DeploymentFlags"=dword:00000001

[HKEY_CLASSES_ROOT\Installer\Products\A180D90768E45F34D976E6FA74EE85E5\SourceList]
"PackageName"="install_flash_player_11_plugin.msi"
"LastUsedSource"="n;1;\\\\fgkks.com\\soft\\Flash\\11.4.402.287\\"

[HKEY_CLASSES_ROOT\Installer\Products\A180D90768E45F34D976E6FA74EE85E5\SourceList\Media]
"DiskPrompt"="[1]"
"1"="DISK1;1"

[HKEY_CLASSES_ROOT\Installer\Products\A180D90768E45F34D976E6FA74EE85E5\SourceList\Net]
"1"=hex(2):5c,00,5c,00,66,00,67,00,6b,00,6b,00,73,00,2e,00,63,00,6f,00,6d,00,\
  5c,00,73,00,6f,00,66,00,74,00,5c,00,46,00,6c,00,61,00,73,00,68,00,5c,00,31,\
  00,31,00,2e,00,34,00,2e,00,34,00,30,00,32,00,2e,00,32,00,38,00,37,00,5c,00,\
  00,00
0
KimputerCommented:
To quote your original question:

"Adobe Flash Player 11 "

I even removed the trailing space to fix your error. But now you show me it should be:
"Adobe Flash Player 11 Plugin"

As programming is quite an exact science, if you give the wrong info, you will get a non-working script.

Use the original script, find:

if ((strValueName = "ProductName") and (strValue = "Adobe Flash Player 11")) then

Open in new window


Replace with:
if ((strValueName = "ProductName") and (strValue = "Adobe Flash Player 11 Plugin")) then

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

jaya31Author Commented:
Hi Kimputer,

This works great, thank much. Apologies, my mistake on the name.
 I just have one follow up question before closing. The subroutine at the bottom of the script refers to deleting keys from HKEY_CURRENT_USER. Again, not a programming\scripting person, just wanted to make sure there was nothing else happening.

I did run it on a test machine and worked deleting the key referring to Adobe, and didn't experience anything adverse. Thanks again.
0
KimputerCommented:
The lower part is indeed a sub routine, and hence it's not really that key, but the key you input when you call the routine. It's indeed prone to misinterpretation, and I should have used a better variable name that would indicate it's a variable and not a fixed value.
0
jaya31Author Commented:
Thanks again, just wanted to make sure. Much appreciated, this is exactly what I needed.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.