在批处理文件中,我正在使用以下内容检查Baseboard信息:
BaseboardCheck.cmd
@echo off
setlocal enabledelayedexpansion
for /f "tokens=1,2* delims==" %%a in ('wmic baseboard get /format:list') DO (
if ["%%a"] EQU ["Product"] (
set PlatformInfo=%%b
if defined PlatformInfo (
echo.!PlatformInfo!
echo.!PlatformInfo!This overwrites the variable
)
)
if ["%%a"] EQU ["Version"] (
set BaseboardVersion=%%b
if defined BaseboardVersion (
echo.!BaseboardVersion!
echo.!BaseboardVersion!This overwrites the variable
)
)
)
上面的问题:当回显出来时,变量将被覆盖,而不是附加。
输出:
DX79SI
This overwrites the variable
AAG28808-600
This overwrites the variable
我想要得到的是:
DX79SI
DX79SIThis overwrites the variable
AAG28808-600
AAG28808-600This overwrites the variable
我已经花了几个小时(并将继续这样做),但希望其他人遇到了这个问题。并希望其他任何遇到此解析问题的人都可以在将来避免这种情况。
由此产生的另一个问题是,它似乎破坏了条件逻辑。
更新
在获得所有帮助之后,我想出了以下解决方案:
for /f "skip=2 tokens=1,2 delims=," %%a in ('wmic baseboard get Product^,Version^,Width /format:csv') do (
set Platform=%%a
set BaseboardVersion=%%b
)
echo.Platform: %Platform%
echo.Version %BaseboardVersion%.
浮云间
慕的地10843