Hi, I'm scratching my head at trying to compare a list of expected patch updates (Patch_List.txt) against what actually is installed on a computer.
I'm using a combination of "WMIC QFE" and Registry queries to return a list of KB updates - The problem is when I query the QFE list, it doesn't return what I want based on ERRORLEVEL.
In normal CMD tests, the command returns the expected ERRORLEVEL as 0 as successful, or 1 as unsuccessful. But in the batch file, it always returns 1.
I've used Google searches to spawn this script... Hopefully someone here can fix the script to return the expected results...
@ECHO OFF
WMIC QFE GET HOTFIXID>%~dp0QFE_list.txt
FOR /f %%a IN (%~dp0Patch_List.txt) DO (
CALL :PATCH_LIST %%a
)
GOTO :EOF
:PATCH_LIST
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s /f "%1">NULL
IF %ERRORLEVEL% EQU 0 ECHO %1: INSTALLED
IF %ERRORLEVEL% NEQ 0 (
ECHO FIND %1
FIND /C "%1" %~dp0QFE_List.txt>NULL
IF %ERRORLEVEL% EQU 0 ECHO %1: QFE INSTALLED
IF %ERRORLEVEL% NEQ 0 ECHO %1: **** NOT INSTALLED! ****
)
..Thanks in advance