Batch file Windows卸载使用注册表查询日志

Batch file Windows卸载使用注册表查询日志,batch-file,registry,wmic,Batch File,Registry,Wmic,首先,向罗布·范德沃德致敬,感谢他精彩的剧本。 他的脚本是针对Windows 7的,不关注企业。然而,他的剧本确实为我们提供了一些非常有价值的见解 其他利用资源: 我们还看到了许多基于VBS和PowerShell的与此相关的脚本。虽然这些都很好,但我们对这些文件格式有一些问题,如下所述 当前问题:我们看到32位和64位卸载注册表项之间的检测似乎无法正常工作。正如Rob的网站在上面指出的那样,我们将FINDSTR与RegExP结合使用。确实尝试删除/R和/C:但可能会在这方面取得重大进展 我们正在

首先,向罗布·范德沃德致敬,感谢他精彩的剧本。 他的脚本是针对Windows 7的,不关注企业。然而,他的剧本确实为我们提供了一些非常有价值的见解

其他利用资源:

我们还看到了许多基于VBS和PowerShell的与此相关的脚本。虽然这些都很好,但我们对这些文件格式有一些问题,如下所述

当前问题:我们看到32位和64位卸载注册表项之间的检测似乎无法正常工作。正如Rob的网站在上面指出的那样,我们将FINDSTR与RegExP结合使用。确实尝试删除/R和/C:但可能会在这方面取得重大进展

我们正在筛选WinZip-即使安装在64位服务器上,也似乎安装在32位卸载位置。这可能不是一个很好的例子

生成的日志正确显示32位:

SOMESERVER
SOMESERVER,"32bit",WinZip Command Line Support Add-On 3.2 
SOMESERVER,"32bit",WinZip 16.5 
SOMESERVER,"32bit",16.5.10095 
SOMESERVER,32BIT,"WinZip Command Line Support Add-On 3.2","", 
SOMESERVER,32BIT,"WinZip 16.5","16.5.10095",2012-07-24 
生成的64位日志显示不正确,我怀疑我们需要清除一两个变量:

ANOTHERSERVER
ANOTHERSERVER,"32bit",WinZip Command Line Support Add-On 3.2 
ANOTHERSERVER,"64bit",WinZip Command Line Support Add-On 3.2 
我们希望日志为64位:

ANOTHERSERVER
ANOTHERSERVER,"32bit",WinZip Command Line Support Add-On 3.2 
ANOTHERSERVER,"64bit",WinZip 16.5 
ANOTHERSERVER,"64bit",16.5.10095 
ANOTHERSERVER,32BIT,"WinZip 16.5","16.5.10095",2012-11-13 
ANOTHERSERVER,64BIT,"WinZip Command Line Support Add-On 3.2","", 
同样,如上所述,WinZip可能是一个不好的例子:

当前脚本代码为:

REM TITLE: Installed Software
REM AUTHOR: Kent Dyer (WITH PIECES PULLED FROM VARIOUS RESOURCES - REFERENCED BELOW)
REM DATE: 2014-02-27
REM VERSION: 1.0 (Initial release)
REM
REM TO DO: This script is to read a text file and does not query AD
REM 
REM Have read the warnings against the use of Win32_Product and in fact does not exist
REM on newer systems.  It just simply errors with the use of WMIC (VBS: http://ss64.com/nt/installed.txt)
REM ISSUE #1: Because of security issues in our enterprise data center, we cannot use VBS without code signing
REM ISSUE #2: PowerShell is certainly an option, but like the batch file as below
REM ISSUE #3: have seen on a certain number of systems where the 32 and 64 bit remote registry key detection
REM The FINDSTR is using with RegExp..
REM is not working properly in some example
REM Geek Uninstaller (http://geekuninstaller.com) shows WinZip-64 (VERSION 16.5.10095) being referenced
REM in the registry at the 32-bit location:
REM HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{CD95F661-A5C4-44F5-A6AA-ECDD91C240D3}
REM
REM ISSUE STATEMENT AND DISCUSSION
REM Have seen a number of scripts out on various sites using VBS and PowerShell
REM However, they do not address if there is no "DisplayName" like the one below
REM and consequently have a number of errors when run
REM Gained some very valuable insight at: Rob van der Woude's Scripting Pages
REM URL: http://www.robvanderwoude.com/files/getuninstall_w7.txt
REM However the page is specific to windows 7 only
REM We have a number of Windows 2003/2008 servers and have a mix of 32 and 64-bit installations
REM WinZip in the example shown does have both 32-bit and 64-bit installations to illustrate
REM the use of this script

REM DEFINE A LIST OF COMPUTERS
SET COMPLIST=installed_computers.txt

REM CREATE A LOG
SET LOGDATA=results.txt

REM SOFTWARE TO SEARCH FOR.  HAVE ONLY USED PARTIAL STRINGS.
REM HAVE NOT USED FULL STRINGS LIKE WinZip 16.5
SET SRCH=WinZip

REM WE NEED TO DELETE THE EXISTING LOG IF IT EXISTS
IF EXIST %LOGDATA% DEL %LOGDATA%

SETLOCAL ENABLEDELAYEDEXPANSION
SET Count32bit=0
SET Count64bit=0
FOR /F "tokens=1" %%A IN (%COMPLIST%) DO (
  SET CNAME=%%A
  ECHO !CNAME! >> %LOGDATA%
REM SECTION TO LIST 32-BIT SOFTWARE
FOR /F "tokens=*" %%A IN ('REG Query \\!CNAME!\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\') DO (
REM USE THIS NEXT LINE TO LIST ALL 32-BIT SOFTWARE
REM USE THIS FOR EVERYTHING... REG Query "\\!CNAME!\%%~A" /F DisplayName /E | FINDSTR /R /I /C:" DisplayName .* .*%~1" >NUL 2>&1
REM USE THIS NEXT LINE TO LIST SPECIFIC 32-bit SOFTWARE
REG Query "\\!CNAME!\%%~A" /F DisplayName /E | FINDSTR  /R /I /C:" DisplayName .* .*%SRCH%*" >NUL 2>&1
    IF NOT ERRORLEVEL 1 (
              SET /A Count32bit += 1
              FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /v DisplayName') DO ECHO !CNAME!,"32bit",%%C >> %LOGDATA%
              FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /v DisplayVersion') DO ECHO !CNAME!,"32bit",%%C >> %LOGDATA%
              )
)
REM
REM SECTION TO LIST 64-BIT SOFTWARE
REM SEEM TO HAVE A BIT OF AN ISSUE WITH
REM WinZip command-line add-on
FOR /F "tokens=*" %%A IN ('REG Query \\!CNAME!\HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\') DO (
REM USE THIS NEXT LINE TO LIST ALL 64-BIT SOFTWARE
REM USE THIS FOR EVERYTHING... REG Query "\\!CNAME!\%%~A" /F DisplayName /E | FINDSTR /R /I /C:" DisplayName .* .*%~1" >NUL 2>&1
REM USE THIS NEXT LINE TO LIST SPECIFC 64-bit SOFTWARE
REG Query "\\!CNAME!\%%~A" /F DisplayName /E | FINDSTR /R /I /C:" DisplayName .* .*%SRCH%*" >NUL 2>&1
    IF NOT ERRORLEVEL 1 (
              SET /A Count64bit += 1
              FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /v DisplayName') DO ECHO !CNAME!,"64bit",%%C >> %LOGDATA%
              FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /v DisplayVersion') DO ECHO !CNAME!,"64bit",%%C >> %LOGDATA%
              )
)

)
    ECHO. >> %LOGDATA%
    ECHO     !Count64bit! 64-bit programs and !Count32bit! 32-bit programs found >> %LOGDATA%
ENDLOCAL
REM TITLE: Installed Software
REM AUTHOR: Kent Dyer (WITH PIECES PULLED FROM VARIOUS RESOURCES - REFERENCED BELOW)
REM DATE: 2014-02-27
REM VERSION: 1.0 (Initial release)
REM
REM TO DO: This script is to read a text file and does not query AD
REM 
REM Have read the warnings against the use of Win32_Product and in fact does not exist
REM on newer systems.  It just simply errors with the use of WMIC (VBS: http://ss64.com/nt/installed.txt)
REM ISSUE #1: Because security issues in our enterprise data center, we cannot use VBS without code signing
REM ISSUE #2: PowerShell is certainly an option, but like the batch file as below
REM ISSUE #3: have seen on a certain number of systems where the 32 and 64 bit remote registry key detection
REM Yout must run this script on a 64-bit machine.  While you can run it on the 32-bit environment, in
REM to see the 64-bit environent, you have to execute this scrip this week.
REM Geek Uninstaller (http://geekuninstaller.com) shows WinZip-64 (VERSION 16.5.10095) being referenced
REM in the registry at the 32-bit location:
REM HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{CD95F661-A5C4-44F5-A6AA-ECDD91C240D3}
REM
REM ISSUE STATEMENT AND DISCUSSION
REM Have seen a number of scripts out on various sites using VBS and PowerShell
REM However, they do not address if there is no "DisplayName" like the one below
REM and consequently have a number of errors when run
REM Gained some very valuable insight at: Rob van der Woude's Scripting Pages
REM URL: http://www.robvanderwoude.com/files/getuninstall_w7.txt
REM However the page is specific to windows 7 only
REM We have a number of Windows 2003/2008 servers and have a mix of 32 and 64-bit installations
REM WinZip in the example shown does have both 32-bit and 64-bit installations to illustrate
REM the use of this script

REM DEFINE A LIST OF COMPUTERS
SET COMPLIST=installed_computers.txt

REM CREATE A LOG
SET LOGDATA=results.txt

REM SOFTWARE TO SEARCH FOR.  HAVE ONLY USED PARTIAL STRINGS.
REM HAVE NOT USED FULL STRINGS LIKE WinZip 16.5
SET SRCH=WinZip

REM WE NEED TO DELETE THE EXISTING LOG IF IT EXISTS
IF EXIST %LOGDATA% DEL %LOGDATA%

ECHO DisplayName,DisplayVersion,InstallDate >> %LOGDATA%

SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "tokens=1" %%A IN (%COMPLIST%) DO (
 SET CNAME=%%A
  rem SET CNAME=LTCRSADEVAP06
  REM ECHO !CNAME! >> %LOGDATA%
REM SECTION TO LIST 32-BIT SOFTWARE
FOR /F "tokens=*" %%A IN ('REG Query \\!CNAME!\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /F "%~1" /D /S 2^>NUL ^| FINDSTR /R /B /C:"HKEY_"') DO (
        REM USE THIS NEXT LINE TO LIST SPECIFC 32-BIT SOFTWARE
        REG Query "\\!CNAME!\%%~A" /F DisplayName /E | FINDSTR /R /I /C:" DisplayName .* .*!SRCH!" >NUL 2>&1
        REM USE THIS NEXT LINE TO LIST ALL 32-BIT SOFTWARE
    REM REG Query "\\!CNAME!\%%~A" /F DisplayName /V /E | FINDSTR /R /I /C:" DisplayName .* .*%~1" >NUL 2>&1
    IF NOT ERRORLEVEL 1 (
        SET /A Count += 1
        FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /F DisplayName    /V /E 2^>NUL ^| FIND /I " DisplayName "')     DO (
         SET DisplayName=%%C
         )
        FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /F DisplayVersion /V /E 2^>NUL ^| FIND /I " DisplayVersion "')  DO (
         SET DisplayVersion=%%C
         )
        FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /F InstallDate    /V /E 2^>NUL ^| FIND /I " InstallDate "')     DO (
            SET InstallDate=%%C
            SET InstallDate=!InstallDate:~0,4!-!InstallDate:~4,2!-!InstallDate:~6!
        )
        ECHO.
        ECHO !CNAME!,32BIT,"!DisplayName!","!DisplayVersion!",!InstallDate! >> %LOGDATA%
        SET DisplayName=
        SET DisplayVersion=
        SET InstallDate=
    )
)

REM IF YOU DO NOT RUN THIS ON A 64-BIT SYSTEM, IT WILL NEVER DETECT 64-BIT SOFTWARE!!
WMIC.EXE Path Win32_Processor Get DataWidth 2>NUL | FIND "64" >NUL
IF ERRORLEVEL 1 (
    ECHO.
    ECHO %Count% programs found
) ELSE (
    SET Count32bit=0
    FOR /F "tokens=*" %%A IN ('REG Query \\!CNAME!\HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall /F "%~1" /D /S 2^>NUL ^| FINDSTR /R /B /C:"HKEY_"') DO (
                REM USE THIS NEXT LINE TO LIST SPECIFC 64-bit SOFTWARE
                REG Query "\\!CNAME!\%%~A" /F DisplayName /E | FINDSTR /R /I /C:" DisplayName .* .*!SRCH!" >NUL 2>&1
                REM USE THIS NEXT LINE TO LIST ALL 64-BIT SOFTWARE
        REM REG Query "\\!CNAME!\%%~A" /F DisplayName /V /E | FINDSTR /R /I /C:" DisplayName .* .*%~1" >NUL 2>&1
        IF NOT ERRORLEVEL 1 (
            SET /A Count32bit += 1
            FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /F DisplayName    /V /E 2^>NUL ^| FIND /I " DisplayName "')     DO (
             SET DisplayName=%%C
             )
            FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /F DisplayVersion /V /E 2^>NUL ^| FIND /I " DisplayVersion "')  DO (
             SET DisplayVersion=%%C
             )
            FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /F InstallDate    /V /E 2^>NUL ^| FIND /I " InstallDate "')     DO (
                SET InstallDate=%%C
                SET InstallDate=!InstallDate:~0,4!-!InstallDate:~4,2!-!InstallDate:~6!
            )
            ECHO.
            ECHO !CNAME!,64BIT,"!DisplayName!","!DisplayVersion!",!InstallDate! >> %LOGDATA%
            SET DisplayName=
            SET DisplayVersion=
            SET InstallDate=
        )
    )
)
)
    ECHO. >> %LOGDATA%
    ECHO     %Count% 64-bit programs and !Count32bit! 32-bit programs found >> %LOGDATA%
PAUSE

我已经设法修复了代码,使它现在可以工作了

我们还看到了许多基于VBS和PowerShell的与此相关的脚本。虽然这些都很好,但我们对这些文件格式有一些问题,如下所述

生成的日志正确显示32位:

SOMESERVER
SOMESERVER,"32bit",WinZip Command Line Support Add-On 3.2 
SOMESERVER,"32bit",WinZip 16.5 
SOMESERVER,"32bit",16.5.10095 
SOMESERVER,32BIT,"WinZip Command Line Support Add-On 3.2","", 
SOMESERVER,32BIT,"WinZip 16.5","16.5.10095",2012-07-24 
结果日志正确显示64位:

ANOTHERSERVER
ANOTHERSERVER,"32bit",WinZip Command Line Support Add-On 3.2 
ANOTHERSERVER,"64bit",WinZip 16.5 
ANOTHERSERVER,"64bit",16.5.10095 
ANOTHERSERVER,32BIT,"WinZip 16.5","16.5.10095",2012-11-13 
ANOTHERSERVER,64BIT,"WinZip Command Line Support Add-On 3.2","", 
当前脚本代码为:

REM TITLE: Installed Software
REM AUTHOR: Kent Dyer (WITH PIECES PULLED FROM VARIOUS RESOURCES - REFERENCED BELOW)
REM DATE: 2014-02-27
REM VERSION: 1.0 (Initial release)
REM
REM TO DO: This script is to read a text file and does not query AD
REM 
REM Have read the warnings against the use of Win32_Product and in fact does not exist
REM on newer systems.  It just simply errors with the use of WMIC (VBS: http://ss64.com/nt/installed.txt)
REM ISSUE #1: Because of security issues in our enterprise data center, we cannot use VBS without code signing
REM ISSUE #2: PowerShell is certainly an option, but like the batch file as below
REM ISSUE #3: have seen on a certain number of systems where the 32 and 64 bit remote registry key detection
REM The FINDSTR is using with RegExp..
REM is not working properly in some example
REM Geek Uninstaller (http://geekuninstaller.com) shows WinZip-64 (VERSION 16.5.10095) being referenced
REM in the registry at the 32-bit location:
REM HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{CD95F661-A5C4-44F5-A6AA-ECDD91C240D3}
REM
REM ISSUE STATEMENT AND DISCUSSION
REM Have seen a number of scripts out on various sites using VBS and PowerShell
REM However, they do not address if there is no "DisplayName" like the one below
REM and consequently have a number of errors when run
REM Gained some very valuable insight at: Rob van der Woude's Scripting Pages
REM URL: http://www.robvanderwoude.com/files/getuninstall_w7.txt
REM However the page is specific to windows 7 only
REM We have a number of Windows 2003/2008 servers and have a mix of 32 and 64-bit installations
REM WinZip in the example shown does have both 32-bit and 64-bit installations to illustrate
REM the use of this script

REM DEFINE A LIST OF COMPUTERS
SET COMPLIST=installed_computers.txt

REM CREATE A LOG
SET LOGDATA=results.txt

REM SOFTWARE TO SEARCH FOR.  HAVE ONLY USED PARTIAL STRINGS.
REM HAVE NOT USED FULL STRINGS LIKE WinZip 16.5
SET SRCH=WinZip

REM WE NEED TO DELETE THE EXISTING LOG IF IT EXISTS
IF EXIST %LOGDATA% DEL %LOGDATA%

SETLOCAL ENABLEDELAYEDEXPANSION
SET Count32bit=0
SET Count64bit=0
FOR /F "tokens=1" %%A IN (%COMPLIST%) DO (
  SET CNAME=%%A
  ECHO !CNAME! >> %LOGDATA%
REM SECTION TO LIST 32-BIT SOFTWARE
FOR /F "tokens=*" %%A IN ('REG Query \\!CNAME!\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\') DO (
REM USE THIS NEXT LINE TO LIST ALL 32-BIT SOFTWARE
REM USE THIS FOR EVERYTHING... REG Query "\\!CNAME!\%%~A" /F DisplayName /E | FINDSTR /R /I /C:" DisplayName .* .*%~1" >NUL 2>&1
REM USE THIS NEXT LINE TO LIST SPECIFIC 32-bit SOFTWARE
REG Query "\\!CNAME!\%%~A" /F DisplayName /E | FINDSTR  /R /I /C:" DisplayName .* .*%SRCH%*" >NUL 2>&1
    IF NOT ERRORLEVEL 1 (
              SET /A Count32bit += 1
              FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /v DisplayName') DO ECHO !CNAME!,"32bit",%%C >> %LOGDATA%
              FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /v DisplayVersion') DO ECHO !CNAME!,"32bit",%%C >> %LOGDATA%
              )
)
REM
REM SECTION TO LIST 64-BIT SOFTWARE
REM SEEM TO HAVE A BIT OF AN ISSUE WITH
REM WinZip command-line add-on
FOR /F "tokens=*" %%A IN ('REG Query \\!CNAME!\HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\') DO (
REM USE THIS NEXT LINE TO LIST ALL 64-BIT SOFTWARE
REM USE THIS FOR EVERYTHING... REG Query "\\!CNAME!\%%~A" /F DisplayName /E | FINDSTR /R /I /C:" DisplayName .* .*%~1" >NUL 2>&1
REM USE THIS NEXT LINE TO LIST SPECIFC 64-bit SOFTWARE
REG Query "\\!CNAME!\%%~A" /F DisplayName /E | FINDSTR /R /I /C:" DisplayName .* .*%SRCH%*" >NUL 2>&1
    IF NOT ERRORLEVEL 1 (
              SET /A Count64bit += 1
              FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /v DisplayName') DO ECHO !CNAME!,"64bit",%%C >> %LOGDATA%
              FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /v DisplayVersion') DO ECHO !CNAME!,"64bit",%%C >> %LOGDATA%
              )
)

)
    ECHO. >> %LOGDATA%
    ECHO     !Count64bit! 64-bit programs and !Count32bit! 32-bit programs found >> %LOGDATA%
ENDLOCAL
REM TITLE: Installed Software
REM AUTHOR: Kent Dyer (WITH PIECES PULLED FROM VARIOUS RESOURCES - REFERENCED BELOW)
REM DATE: 2014-02-27
REM VERSION: 1.0 (Initial release)
REM
REM TO DO: This script is to read a text file and does not query AD
REM 
REM Have read the warnings against the use of Win32_Product and in fact does not exist
REM on newer systems.  It just simply errors with the use of WMIC (VBS: http://ss64.com/nt/installed.txt)
REM ISSUE #1: Because security issues in our enterprise data center, we cannot use VBS without code signing
REM ISSUE #2: PowerShell is certainly an option, but like the batch file as below
REM ISSUE #3: have seen on a certain number of systems where the 32 and 64 bit remote registry key detection
REM Yout must run this script on a 64-bit machine.  While you can run it on the 32-bit environment, in
REM to see the 64-bit environent, you have to execute this scrip this week.
REM Geek Uninstaller (http://geekuninstaller.com) shows WinZip-64 (VERSION 16.5.10095) being referenced
REM in the registry at the 32-bit location:
REM HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{CD95F661-A5C4-44F5-A6AA-ECDD91C240D3}
REM
REM ISSUE STATEMENT AND DISCUSSION
REM Have seen a number of scripts out on various sites using VBS and PowerShell
REM However, they do not address if there is no "DisplayName" like the one below
REM and consequently have a number of errors when run
REM Gained some very valuable insight at: Rob van der Woude's Scripting Pages
REM URL: http://www.robvanderwoude.com/files/getuninstall_w7.txt
REM However the page is specific to windows 7 only
REM We have a number of Windows 2003/2008 servers and have a mix of 32 and 64-bit installations
REM WinZip in the example shown does have both 32-bit and 64-bit installations to illustrate
REM the use of this script

REM DEFINE A LIST OF COMPUTERS
SET COMPLIST=installed_computers.txt

REM CREATE A LOG
SET LOGDATA=results.txt

REM SOFTWARE TO SEARCH FOR.  HAVE ONLY USED PARTIAL STRINGS.
REM HAVE NOT USED FULL STRINGS LIKE WinZip 16.5
SET SRCH=WinZip

REM WE NEED TO DELETE THE EXISTING LOG IF IT EXISTS
IF EXIST %LOGDATA% DEL %LOGDATA%

ECHO DisplayName,DisplayVersion,InstallDate >> %LOGDATA%

SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "tokens=1" %%A IN (%COMPLIST%) DO (
 SET CNAME=%%A
  rem SET CNAME=LTCRSADEVAP06
  REM ECHO !CNAME! >> %LOGDATA%
REM SECTION TO LIST 32-BIT SOFTWARE
FOR /F "tokens=*" %%A IN ('REG Query \\!CNAME!\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /F "%~1" /D /S 2^>NUL ^| FINDSTR /R /B /C:"HKEY_"') DO (
        REM USE THIS NEXT LINE TO LIST SPECIFC 32-BIT SOFTWARE
        REG Query "\\!CNAME!\%%~A" /F DisplayName /E | FINDSTR /R /I /C:" DisplayName .* .*!SRCH!" >NUL 2>&1
        REM USE THIS NEXT LINE TO LIST ALL 32-BIT SOFTWARE
    REM REG Query "\\!CNAME!\%%~A" /F DisplayName /V /E | FINDSTR /R /I /C:" DisplayName .* .*%~1" >NUL 2>&1
    IF NOT ERRORLEVEL 1 (
        SET /A Count += 1
        FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /F DisplayName    /V /E 2^>NUL ^| FIND /I " DisplayName "')     DO (
         SET DisplayName=%%C
         )
        FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /F DisplayVersion /V /E 2^>NUL ^| FIND /I " DisplayVersion "')  DO (
         SET DisplayVersion=%%C
         )
        FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /F InstallDate    /V /E 2^>NUL ^| FIND /I " InstallDate "')     DO (
            SET InstallDate=%%C
            SET InstallDate=!InstallDate:~0,4!-!InstallDate:~4,2!-!InstallDate:~6!
        )
        ECHO.
        ECHO !CNAME!,32BIT,"!DisplayName!","!DisplayVersion!",!InstallDate! >> %LOGDATA%
        SET DisplayName=
        SET DisplayVersion=
        SET InstallDate=
    )
)

REM IF YOU DO NOT RUN THIS ON A 64-BIT SYSTEM, IT WILL NEVER DETECT 64-BIT SOFTWARE!!
WMIC.EXE Path Win32_Processor Get DataWidth 2>NUL | FIND "64" >NUL
IF ERRORLEVEL 1 (
    ECHO.
    ECHO %Count% programs found
) ELSE (
    SET Count32bit=0
    FOR /F "tokens=*" %%A IN ('REG Query \\!CNAME!\HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall /F "%~1" /D /S 2^>NUL ^| FINDSTR /R /B /C:"HKEY_"') DO (
                REM USE THIS NEXT LINE TO LIST SPECIFC 64-bit SOFTWARE
                REG Query "\\!CNAME!\%%~A" /F DisplayName /E | FINDSTR /R /I /C:" DisplayName .* .*!SRCH!" >NUL 2>&1
                REM USE THIS NEXT LINE TO LIST ALL 64-BIT SOFTWARE
        REM REG Query "\\!CNAME!\%%~A" /F DisplayName /V /E | FINDSTR /R /I /C:" DisplayName .* .*%~1" >NUL 2>&1
        IF NOT ERRORLEVEL 1 (
            SET /A Count32bit += 1
            FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /F DisplayName    /V /E 2^>NUL ^| FIND /I " DisplayName "')     DO (
             SET DisplayName=%%C
             )
            FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /F DisplayVersion /V /E 2^>NUL ^| FIND /I " DisplayVersion "')  DO (
             SET DisplayVersion=%%C
             )
            FOR /F "tokens=2*" %%B IN ('REG Query "\\!CNAME!\%%~A" /F InstallDate    /V /E 2^>NUL ^| FIND /I " InstallDate "')     DO (
                SET InstallDate=%%C
                SET InstallDate=!InstallDate:~0,4!-!InstallDate:~4,2!-!InstallDate:~6!
            )
            ECHO.
            ECHO !CNAME!,64BIT,"!DisplayName!","!DisplayVersion!",!InstallDate! >> %LOGDATA%
            SET DisplayName=
            SET DisplayVersion=
            SET InstallDate=
        )
    )
)
)
    ECHO. >> %LOGDATA%
    ECHO     %Count% 64-bit programs and !Count32bit! 32-bit programs found >> %LOGDATA%
PAUSE