【发布时间】:2022-01-02 00:43:18
【问题描述】:
我发现this 发布了关于使用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 }
这绝对没问题,但是否也可以合并 Description 和 InstalledOn wmic 信息,以便输出显示以下内容:
HotfixID InstalledOn 说明
使用上面的代码,我可以单独获取每个代码,但不能全部一起获取,因为 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%
希望您能提供帮助。
【问题讨论】:
标签: windows batch-file wmic hotfix