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
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