Parsing WMIC output

后端 未结 1 1756
孤独总比滥情好
孤独总比滥情好 2021-01-28 06:42

I have a BAT script that is supposed to read the current screen resolution to variables. I get the screen resolution with the wmic desktopmonitor get screenwidth /value

相关标签:
1条回答
  • 2021-01-28 07:39

    echo var: %screenwidth% <--- You can't set and use a variable within a loop without some special techniques, like delayed expansion.

    Does this do what you need?

    @echo off
    set "screenwidth="
    for /F "tokens=2 delims==" %%F in ('wmic desktopmonitor get screenwidth /value') do (
        if not defined screenwidth set screenwidth=%%F
    )
    pause
    
    0 讨论(0)
提交回复
热议问题