networking - Local Area Connection State: Batch File -
i trying write batch script identify whether or not "local area connection" adapter plugged in or not.
set nicvalue= /f "delims=" %%a in ('netsh interface show interface "local area connection"') @set nicvalue=%%a echo %nicvalue% if "%nicvalue%"=="connect state: connected" echo on
i able right output , save variable called %nicvalue%
, however, not able run 'if' command based off of output. of right now, trying echo "on" if batch file can see "connect state:" , "connected", @ loss. appreciated!
why don't filter :
, in
for /f
loop , clean value. so:
set nicvalue= /f "tokens=3 delims=: " %%a in ('netsh interface show interface "local area connection"') @set nicvalue=%%a echo %nicvalue% if "%nicvalue%"=="connected" echo connected
but think issue using echo on
statement, you're turning echo
on
state, need rephrase else echo connected
Comments
Post a Comment