@echo off
setlocal enabledelayedexpansion
::just a sample adapter here:
set "adapter=Ethernet adapter Local Area Connection"
set adapterfound=false
echo Network Connection Test
for /f "usebackq tokens=1-2 delims=:" %%f in (`ipconfig /all`) do
(
set "item=%%f"
if /i "!item!"=="!adapter!"
(
set adapterfound=true
)
else if not "!item!"=="!item:IP Address=!" if "!adapterfound!"=="true"
(
echo Your IP Address is: %%g
set adapterfound=false
)
)
VERY new to the party, can someone explain a few things here:
- What does setlocal enabledelayedexpansion do in this particular case?
- What does usebackq do? (I tried to see this, but did not quite understand)
- How was the variable %% g initialized and global or local?
Thank you for your time!
source
share