0

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

4

2 に答える 2

1

これはほぼ期待どおりです。

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
REM SETLOCAL ENABLEDELAYEDEXPANSION
CLS
echo.Tim: uninstall (old/previous) Adobe ShockWave/Flash...

CALL "\\dc01.lksvdd.local\netlogon\Log_management.bat" >nul 2>&1

:: RUN_Once
IF NOT EXIST "%systemroot%\LOGS\LKSVDD\Tim\uninstall_(shockwave)flash_12+11.txt" (GOTO Uninstall_Adobe-Addons) ELSE GOTO:EOF
GOTO:EXIT


:Uninstall_Adobe-Addons
rem uninstall old adobe shockwave/flash installations; new adobe shockwave/flash setup pushed with GPO...

wmic product where "name like 'Adobe Flash Player 11%%'" call uninstall /nointeractive      > "%systemroot%\LOGS\LKSVDD\Tim\uninstall_(shockwave)flash_12+11.txt" 2>&1
wmic product where "name like 'Adobe Flash Player 10%%'" call uninstall /nointeractive          > "%systemroot%\LOGS\LKSVDD\Tim\uninstall_(shockwave)flash_12+11.txt" 2>&1
wmic product where "name like 'Adobe Shockwave Player 12%%'" call uninstall /nointeractive >> "%systemroot%\LOGS\LKSVDD\Tim\uninstall_(shockwave)flash_12+11.txt" 2>&1
wmic product where "name like 'Adobe Shockwave Player 11%%'" call uninstall /nointeractive     >> "%systemroot%\LOGS\LKSVDD\Tim\uninstall_(shockwave)flash_12+11.txt" 2>&1

rem Abort possible ShutDown..................
"%windir%\system32\shutdown.exe" /a >nul 2>&1


:EXIT
ECHO #runTimeStamp -4- "uninstall_adobe-addons.cmd" [%DATE% %TIME%] EOF >> "%systemroot%\LOGS\LKSVDD\Tim\uninstall_(shockwave)flash_12+11.txt" 2>&1

rem echo.
REM script date: 16-07-2013
rem echo.
rem PAUSE
ENDLOCAL
GOTO:EOF

「Adobe Flash Player」はアンインストール/削除されますが、「Adobe Flash Player」はそうではありません??? それは正しいプログラムの説明ですが、何らかの理由で認識されません。理由はわかりませんか?

于 2013-07-16T17:37:44.263 に答える