我想搜索这些注册表项(可能带有“ REG Query
”):
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
AND“ Find
”或“ FindStr
”特定变量并显示结果(echo
?)
这个脚本有点像我想要实现的目标**:**
@ECHO OFF
:: Windows 7 only
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
VER | FINDSTR /R /E /C:" 6\.[01]\.[0-9\.]*\]" >NUL || GOTO Syntax
:: Check command line arguments
IF "%~1"=="" GOTO Syntax
IF NOT "%~2"=="" GOTO Syntax
ECHO "%~1" | FINDSTR /R /C:"[/?]" >NUL && GOTO Syntax
SETLOCAL ENABLEDELAYEDEXPANSION
SET Count=0
FOR /F "tokens=*" %%A IN ('REG Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /F "%~1" /D /S 2^>NUL ^| FINDSTR /R /B /C:"HKEY_"') DO (
REG Query "%%~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 "%%~A" /F DisplayName /V /E 2^>NUL ^| FIND /I " DisplayName "') DO ECHO Program Name = %%C
FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F DisplayVersion /V /E 2^>NUL ^| FIND /I " DisplayVersion "') DO ECHO Program Version = %%C
FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F InstallDate /V /E 2^>NUL ^| FIND /I " InstallDate "') DO (
SET InstallDate=%%C
ECHO Install Date = !InstallDate:~0,4!-!InstallDate:~4,2!-!InstallDate:~6!
)
FOR /F "tokens=7 delims=\" %%B IN ("%%~A") DO ECHO Unique Identifier = %%B
FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F UninstallString /V /E ^| FIND /I " UninstallString "') DO ECHO Uninstall String = %%C
ECHO.
)
)
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 HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall /F "%~1" /D /S 2^>NUL ^| FINDSTR /R /B /C:"HKEY_"') DO (
REG Query "%%~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 "%%~A" /F DisplayName /V /E 2^>NUL ^| FIND /I " DisplayName "') DO ECHO Program Name = %%C
FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F DisplayVersion /V /E 2^>NUL ^| FIND /I " DisplayVersion "') DO ECHO Program Version = %%C
FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F InstallDate /V /E 2^>NUL ^| FIND /I " InstallDate "') DO (
SET InstallDate=%%C
ECHO Install Date = !InstallDate:~0,4!-!InstallDate:~4,2!-!InstallDate:~6!
)
FOR /F "tokens=7 delims=\" %%B IN ("%%~A") DO ECHO Unique Identifier = %%B
FOR /F "tokens=2*" %%B IN ('REG Query "%%~A" /F UninstallString /V /E ^| FIND /I " UninstallString "') DO ECHO Uninstall String = %%C
ECHO.
)
)
ECHO.
ECHO %Count% 64-bit programs and !Count32bit! 32-bit programs found
)
ENDLOCAL
GOTO:EOF
:Syntax
ECHO.
ECHO GetUninstall.bat, Version 2.00 for Windows Vista and later
ECHO List or search uninstall command lines
ECHO.
ECHO Usage: GETUNINSTALL.BAT "filter"
ECHO.
ECHO Where: "filter" narrows down the search result to programs whose
ECHO uninstall data contains the string "filter"
ECHO.
ECHO Example: GETUNINSTALL.BAT "Adobe Reader"
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
:: Set return code for Windows NT 4 or later
IF "%OS%"=="Windows_NT" COLOR 00
问题:
它确实显示了所有找到的卸载字符串,如“ %1
”所述,并且适用于“Windows 7 PRO SP1”,但不适用于“Windows XP Pro SP3”,我似乎无法让它在 XP 上运行......
REM IF NOT "%OS%"=="Windows_NT" GOTO Syntax
REM VER | FINDSTR /R /E /C:" 6\.[01]\.[0-9\.]*\]" >NUL || GOTO Syntax
/\ 当然没那么容易;-p /\