First post here, so apologies if I don't do this quite right.
I'm trying to output the OS version on a remote Windows PC, but I keep getting unwanted data. Executing this batch file:
@echo off
set /p hostname=PC hostname?
echo.
FOR /F "skip=1 tokens=*" %%A in ('wmic /node:%hostname% OS get caption') DO echo %%A
echo.
pause
Returns this result:
Microsoft Windows 7 Professional
Echo is off.
I was able to remove the Caption
output using skip=1
but I don't understand where the echo
command is coming from. Splitting out the commands didn't help, but turning echo on shows that, apparently, the looped wmic command is outputting echo
after outputting the OS version, so, obviously, when echo is off, I get the final output: Echo is off
. Can anyone help me understand why the echo
output is happening?