如題
手邊有兩個批次檔
請問有辦法透過 A) 檢查
Not install 的再接著 B) 進行安裝嗎?
舉例A)的Patch_list.txt 要看是否有這三支
KB4034679
KB4048690
KB4054521
假設其中 not install 的是KB4054521
再給B)的批次進行安裝
還是A) 的 not install 直接改成進行安裝 而非秀出 ECHO not install
A)檢查是否安裝清單中的hotfix
@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 "HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall" /s /f "%1">NULL.txt
IF %ERRORLEVEL% EQU 0 ECHO %1: INSTALLED
IF %ERRORLEVEL% NEQ 0 (
ECHO FIND %1
FIND /C "%1" %~dp0QFE_List.txt>NULL.txt
IF ERRORLEVEL 0 ECHO %1: QFE INSTALLED
IF ERRORLEVEL 1 ECHO %1: **** NOT INSTALLED! ****
)
B)一次批次安裝目錄中所有 msu更新檔
@echo off
CLS
TITLE WINDOWS UPDATE INSTALLER!
echo.
echo Getting Ready Windows Update
echo Installing Windows Updates...
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
FOR /R "%~dp0" %%A IN (*.MSU) DO (
ECHO= Installing %%~nA
>NUL TIMEOUT /t 3
WUSA "%%A" /quiet /norestart)
echo Done!
請參考
1.將底下批次指存成BAT檔
2.放到更新檔同目錄中
3.在目標電腦執行
Echo Off
For /f "Skip=1 Delims= " %%i In ('WMIC QFE GET HOTFIXID') Do Set %%i=Y 2>Nul
For /f %%j In ('Dir /b *.msu') Do If Not Defined %%~nj WUSA %%j /quiet /norestart
如需美化請自行修改