使用 wmic 查看已安装列表 Hotfixes/Patches(修补程序 ID、安装时间和说明)

Viewing a list of Installed Hotfixes/Patches using wmic (HotfixID, InstalledOn and Description)

我发现 this post 关于使用 wmic qfe list full 获取已安装修补程序列表,@Hackoo 回复如下:

@echo off
Title wmic to get HotfixID
Setlocal EnableDelayedExpansion
echo "patches" : {
set "patches=wmic qfe get HotfixID"
for /f "skip=1" %%i in ('%patches%') do for /f "delims=" %%j in ("%%i") do (
    set /a count=count+1
    echo "!count!" : "%%j",
)
echo }

这绝对没问题,但是否也可以合并 DescriptionInstalledOn wmic 信息,以便输出显示以下:

HotfixID InstalledOn Description

使用上面的代码,我可以单独获取每个但不能一起获取,因为 InstalledOn / Description 似乎重复了第一个值。

然后我超出了我的知识水平并尝试了以下(不起作用):

for /f "tokens=1,2,3 skip=1 delims=," %%a in ('%SystemRoot%\System32\wbem\wmic.exe qfe get HotfixID,InstalledOn,Description') do (
    set "hotfix_number=%%~a"
    set "hotfix_installed=%%~b"
    set "hotfix_description=%%~c"
)
echo %hotfix_number% installed on %hotfix_installed% - %hotfix_description%

在此希望您能提供帮助。

这有帮助吗?

@For /F "Skip=2 Tokens=1,* Delims=," %%G In ('%SystemRoot%\System32\wbem\WMIC.exe QFE Get Description^, HotFixID^, InstalledOn /Format:CSV 2^>NUL') Do @For /F "Tokens=1-3 Delims=," %%I In ("%%H") Do @Echo %%J installed on %%K - %%I