Last active
May 17, 2017 02:12
-
-
Save noonworks/72c4cb15ff36bdeadbd4f3747e257a22 to your computer and use it in GitHub Desktop.
MS17-010のパッチ適用状況確認用バッチ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: https://blogs.technet.microsoft.com/jpwsus/2017/05/15/wannacrypt-ms17-010-wsus/ | |
:: https://en.wikipedia.org/wiki/Ver_(command) | |
set RUN_AS_CMD=0 | |
if "%1"=="/c" ( set RUN_AS_CMD=1 ) | |
echo OS確認中... | |
ver | find /I "Version 5.1." > nul | |
if %ERRORLEVEL% equ 0 goto NOT_SUPPORTED_BUT_PATCH | |
ver | find /I "Version 5.2." > nul | |
if %ERRORLEVEL% equ 0 goto NOT_SUPPORTED_BUT_PATCH | |
ver | find /I "Version 6.0." > nul | |
if %ERRORLEVEL% equ 0 goto NOT_SUPPORTED_BUT_PATCH | |
ver | find /I "Version 6.1." > nul | |
if %ERRORLEVEL% equ 0 goto WIN7_OR_2008R2 | |
ver | find /I "Version 6.2." > nul | |
if %ERRORLEVEL% equ 0 goto CHECK_WIN8_OR_2012 | |
ver | find /I "Version 6.3." > nul | |
if %ERRORLEVEL% equ 0 goto WIN81_OR_2012R2 | |
ver | find /I "Version 6.4." > nul | |
if %ERRORLEVEL% equ 0 goto WIN10_TP_IP | |
ver | find /I "Version 10.0.9926" > nul | |
if %ERRORLEVEL% equ 0 goto WIN10_TP_IP | |
ver | find /I "Version 10.0.10041" > nul | |
if %ERRORLEVEL% equ 0 goto WIN10_TP_IP | |
ver | find /I "Version 10.0.10049" > nul | |
if %ERRORLEVEL% equ 0 goto WIN10_TP_IP | |
ver | find /I "Version 10.0.14915" > nul | |
if %ERRORLEVEL% equ 0 goto WIN10_TP_IP | |
ver | find /I "Version 10.0.10240" > nul | |
if %ERRORLEVEL% equ 0 goto CHECK_WIN10_1507_OR_LTSB2015 | |
ver | find /I "Version 10.0.10586" > nul | |
if %ERRORLEVEL% equ 0 goto WIN10_1511 | |
ver | find /I "Version 10.0.14393" > nul | |
if %ERRORLEVEL% equ 0 goto WIN10_1607_OR_2016 | |
ver | find /I "Version 10.0.15063" > nul | |
if %ERRORLEVEL% equ 0 goto WIN10_1703_OR_LATER | |
echo ×OSが取得できません。管理者に連絡して確認してください。 | |
ver | |
set RESULTCODE=1 | |
goto EXIT_OR_PAUSE | |
:CHECK_WIN8_OR_2012 | |
systeminfo | find "Windows Server 2012" > nul | |
if %ERRORLEVEL% equ 0 goto S2012 | |
goto NOT_SUPPORTED_BUT_PATCH | |
:CHECK_WIN10_1507_OR_LTSB2015 | |
reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v ProductName | find "LTSB" > nul | |
if %ERRORLEVEL% equ 0 goto WIN10_LTSB2015 | |
goto WIN10_1507 | |
::--------------------------- | |
:WIN10_TP_IP | |
echo ×Windows 10 Technical Preview / Windows 10 Insider Preview | |
echo ×OSサポート切れ×買い替えもしくはアップグレードが必要 | |
echo ×適用可能なパッチなし | |
set RESULTCODE=1 | |
goto EXIT_OR_PAUSE | |
:NOT_SUPPORTED_BUT_PATCH | |
echo ×Windows XP / Windows Vista / Windows 8 | |
echo ×Windows Server 2003 / Windows Server 2008 | |
echo ×OSサポート切れ×買い替えもしくはアップグレードが必要 | |
set KBQUERY=KB4012598 | |
goto SEARCH_KB | |
:WIN10_1507 | |
echo ×Windows 10 Threshold 1 (Version 1507) | |
echo ×OSサポート切れ×買い替えもしくはアップグレードが必要 | |
set KBQUERY=KB4012606 KB4015221 KB4019474 | |
goto SEARCH_KB | |
:WIN7_OR_2008R2 | |
echo ○Windows 7 / Windows Server 2008 R2 | |
set KBQUERY=KB4012212 KB4012215 KB4015549 KB4019264 | |
goto SEARCH_KB | |
:S2012 | |
echo ○Windows Server 2012 | |
set KBQUERY=KB4012214 KB4012217 KB4015551 KB4019216 | |
goto SEARCH_KB | |
:WIN81_OR_2012R2 | |
echo ○Windows 8.1 / Windows Server 2012 R2 | |
set KBQUERY=KB4012213 KB4012216 KB4015550 KB4019215 | |
goto SEARCH_KB | |
:WIN10_LTSB2015 | |
echo ○Windows 10 LTSB 2015 | |
set KBQUERY=KB4012606 KB4015221 KB4019474 | |
goto SEARCH_KB | |
:WIN10_1511 | |
echo ○Windows 10 Threshold 2 November Update Version 1511 | |
set KBQUERY=KB4013198 KB4015219 KB4019473 | |
goto SEARCH_KB | |
:WIN10_1607_OR_2016 | |
echo ○Windows 10 Redstone 1 Anniversary Update Version 1607 | |
echo ○Windows Server 2016 / Windows 10 LTSB 2016 | |
set KBQUERY=KB4013429 KB4015438 KB4015217 KB4019472 | |
goto SEARCH_KB | |
:WIN10_1703_OR_LATER | |
echo ○Windows 10 Redstone 2 Creators Update Version 1703 以降 | |
echo ○パッチ不要 | |
set RESULTCODE=0 | |
goto EXIT_OR_PAUSE | |
::--------------------------- | |
:SEARCH_KB | |
echo パッチ適用確認中... | |
wmic qfe list | findstr "%KBQUERY%" > nul | |
if %ERRORLEVEL% equ 0 ( | |
echo ○パッチ適用済み | |
) else ( | |
echo ×パッチ未適用×Windows Updateが必要 | |
echo ×必要KBは以下のどれかひとつ: %KBQUERY% | |
set RESULTCODE=1 | |
goto EXIT_OR_PAUSE | |
) | |
set RESULTCODE=0 | |
goto EXIT_OR_PAUSE | |
::--------------------------- | |
:EXIT_OR_PAUSE | |
if %RUN_AS_CMD% equ 0 pause | |
exit /b %RESULTCODE% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment