How can I use VBScript to enumerate HKEY_CLASSES_ROOT\Installer\Products and delete a key and all subkeys only if specific REG_SZ data exists within it?
Hi everyone,
I've run into a bit of a problem, something happens with installations of Adobe Flash on the workstations in my environment, and it's causing them to give an error when you try to uninstall it. We are pushing Adobe Flash out via the .msi's with group policy(software installation policy), and the problem comes in when technicians are constantly having to visit workstations to search for a particular registry key, delete it manually, and then Adobe Flash will install on the next reboot. Let me explain a bit more,
To fix this error on an affected workstation you have to search under "HKEY_CLASSES_ROOT\Installer\Products", and under one of the subkeys here, such as "30AC997E64E77EA47A6B9E40CCDF5192", you will find one with a REG_SZ value of "ProductName", it's data is "Adobe Flash Player 11 ActiveX". The problem is we have to search each one of these lengthly subkeys for the one that belongs to the Adobe Flash installation. Once we find it and remove the entire "30AC997E64E77EA47A6B9E40CCDF5192" that has the REG_SZ value of "ProductName" data "Adobe Flash Player 11 ActiveX", we can reboot the workstations, and things work great.
The problem I'm really having is on every workstation the "30AC997E64E77EA47A6B9E40CCDF5192" used here is only an example, this string is random from machine-to-machine, it's generated during the Adobe Flash installation. This is where I'm stuck having to make the script search and evaluate everything under HKEY_CURRENT_USER\Installer\Products.
What can I do fellas, is it even possible?
Here's a screenshot for a little more clarity:
http://i.imgur.com/aAqYl.jpg
Answers (5)
Thanks for the input everyone, here is the working code for future reference! @echo off set product=Adobe Flash Player 11 ActiveX for /F "delims=" %%a in ('reg query HKEY_CLASSES_ROOT\Installer\Products') do call :Sub %%a goto :eof :Sub set key= reg query "%*" | find /i "%product%" && set key=%* if "%key%"=="" goto :eof reg query "%*" | find /i "%product%" echo Y|reg delete "%key%"
Thanks for the input everyone, here is the working code for future reference!
@echo off
set product=Adobe Flash Player 11 ActiveX
for /F "delims=" %%a in ('reg query HKEY_CLASSES_ROOT\Installer\Products') do call :Sub %%a
goto :eof
:Sub
set key=
reg query "%*" | find /i "%product%" && set key=%*
if "%key%"=="" goto :eof
reg query "%*" | find /i "%product%"
echo Y|reg delete "%key%"
This should get you started.
http://us.generation-nt.com/answer/script-search-delete-registry-keys-help-30470632.html
Note that HKCR = &H80000000
Comments:
-
Thanks andemats, - LogicBomb 12 years ago
Use the uninstaller from Adobe for Flash player:
http://helpx.adobe.com/flash-player/kb/uninstall-flash-player-windows.html
Here's what I have so far, it's a batch file and someone from microsoft technet helped put it together. It does the job great, but it doesn't remove the key, only reports it via output.txt.
Can anyone help with where I might put the "reg delete" syntax in all of this?
@echo off
set product=Adobe Flash Player 11 ActiveX
if exist output.txt del output.txt
for /F %%a in ('reg query HKEY_CLASSES_ROOT\Installer\Products') do call :Sub %%a
notepad output.txt
goto :eof
:Sub
reg query %1 | find /i "%product%" >> output.txt && echo %* >> output.txt
Comments:
-
looks like you have an answer from another site
http://social.technet.microsoft.com/Forums/en/ITCG/thread/e8d652a4-1047-4065-9f8e-45c5943e4a80 - SMal.tmcc 12 years ago
have you tried MS's uninstaller
http://support.microsoft.com/mats/Program_Install_and_Uninstall