none
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?

    Question

  • 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

           
    • Edited by Ysosrs Monday, August 20, 2012 1:49 AM edit
    Monday, August 20, 2012 1:38 AM

Answers

  • Instead of outputting the key that contains what I'm looking for, how can I delete it without any prompts?

    Thanks very much for your help!

    Did you try opening a command prompt and typing

    reg /?
    reg delete /?
    It is quite straightforward to delete a registry key because someone else did all the hard work when creating reg.exe.

    Note also that deleting registry keys without first creating a System Restore point is risky stuff.

    @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%"

    • Marked as answer by Ysosrs Tuesday, August 21, 2012 3:53 AM
    Monday, August 20, 2012 3:26 PM

All replies

  • While you could write some VB Script to do this (with the emphasis on "you" . . .), here is a simple batch file that will do most of the job. You can easily add a reg /del command to delete the key(s) it finds.

    @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

    Monday, August 20, 2012 9:34 AM
  • You should be using the correct tool for this as it will fo all of that and more.  It does a complete cleanup of the registry and can be deployed via Group Policy.

    This is the offficial Adobe tool downloadable from the Adobe site.

    1. Download the uninstaller for Flash Player

    The Flash Player uninstaller executes on both 64-bit and 32-bit version of the Windows operating systems.

    Save the file in a location where you can find it easily after you restart your computer. For example, save it on your Windows desktop.

    Note: To uninstall Flash Player beta, use the corresponding Flash Player beta uninstaller available in Adobe Labs.


    ¯\_(ツ)_/¯

    Monday, August 20, 2012 12:02 PM
  • While you could write some VB Script to do this (with the emphasis on "you" . . .), here is a simple batch file that will do most of the job. You can easily add a reg /del command to delete the key(s) it finds.

    @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

    This is excellent, it returns the exact key I'm looking for. 

    You mention easily adding a reg /del command, and I've been sitting here for some time trying to figure out the syntax with not much luck.

    Instead of outputting the key that contains what I'm looking for, how can I delete it without any prompts?

    Thanks very much for your help!

    Monday, August 20, 2012 2:42 PM
  • You should be using the correct tool for this as it will fo all of that and more.  It does a complete cleanup of the registry and can be deployed via Group Policy.

    This is the offficial Adobe tool downloadable from the Adobe site.

    1. Download the uninstaller for Flash Player

    The Flash Player uninstaller executes on both 64-bit and 32-bit version of the Windows operating systems.

    Save the file in a location where you can find it easily after you restart your computer. For example, save it on your Windows desktop.

    Note: To uninstall Flash Player beta, use the corresponding Flash Player beta uninstaller available in Adobe Labs.


    ¯\_(ツ)_/¯

    Thanks, even their uninstaller pukes on an affected workstation and doesn't remove Adobe Flash... the only way seems to remove the key in question.  I appreciate your response and will keep the uninstaller handy :)

    Monday, August 20, 2012 2:43 PM
  • Building on Oberwald's approach, I think this should do the job ...

    @echo off
    set product=Adobe Flash Player 11 ActiveX

    for /F %%a in (
      'reg query HKEY_CLASSES_ROOT\Installer\Products') do (
     reg query %%a | find /i "%product%" > nul && reg delete "%%a" /f)


    Tom Lavedas

    Monday, August 20, 2012 3:24 PM
  • Instead of outputting the key that contains what I'm looking for, how can I delete it without any prompts?

    Thanks very much for your help!

    Did you try opening a command prompt and typing

    reg /?
    reg delete /?
    It is quite straightforward to delete a registry key because someone else did all the hard work when creating reg.exe.

    Note also that deleting registry keys without first creating a System Restore point is risky stuff.

    @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%"

    • Marked as answer by Ysosrs Tuesday, August 21, 2012 3:53 AM
    Monday, August 20, 2012 3:26 PM
  • Instead of outputting the key that contains what I'm looking for, how can I delete it without any prompts?

    Thanks very much for your help!

    Did you try opening a command prompt and typing

    reg /?
    reg delete /?
    It is quite straightforward to delete a registry key because someone else did all the hard work when creating reg.exe.

    Note also that deleting registry keys without first creating a System Restore point is risky stuff.

    @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%"

    Thank you, thank you, thank you!  It works!  You really saved my butt Oberwald :)  thanks for your input as well, Tom.
    Tuesday, August 21, 2012 3:53 AM