これらのレジストリ キーを検索したい (おそらく " 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 /\