Created
August 16, 2017 12:45
-
-
Save phyoewaipaing/06e5dea52392cd78e9463fb3d1e872f5 to your computer and use it in GitHub Desktop.
Check if computer restart is Pending after windows update batch script
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
::##check if update pending reboot key exists | |
@echo off | |
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" >nul 2>&1 | |
IF NOT %ERRORLEVEL% == 0 goto Not_Pending_Restart | |
echo System Reboot Pending: Yes | |
::##check if the time since update has been pending reboot | |
for /f "tokens=3,4" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" /f "RebootRequiredSince" ^| findstr "REG_SZ"') do echo Pending since: %%a %%b | |
for /f %%i in ('wmic qfe list ^| find "KB" /c') do echo Number of Installed Updates: %%i | |
goto EOF | |
:Not_Pending_Restart | |
echo System Reboot Pending: No | |
for /f %%i in ('wmic qfe list ^| find "KB" /c') do echo Number of Installed Updates: %%i | |
:EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment