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

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -