I want to return the Default Gateway like i have for the IPv4 but it returns Blank.
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "IPv4"') do set ip=%%b
set ip=%ip:~1%
echo.
echo IP Address is: %ip%
echo.
This is what i have so far but it returns blank, i have tried to alter it but it still returns a blank answer.
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "Default"') do set ip=%%b
set ip=%ip:~2%
echo.
echo The Gateway is: %ip%
echo.
Any ideas how i can do this. and return the default gateway for a given Computer.
In the Command Prompt window, type “ipconfig” and press “Enter/Return” on your keyboard. You will see a lot of information generated in this window. If you scroll up you should see “Default Gateway” with the device's IP address listed to the right of it.
In the "Open:" field, type cmd , and then click OK. This will open the command prompt. At the prompt, enter ipconfig . This will display your network information, including your default gateway.
Here's a WMIC script:
@echo off
for /f "tokens=2,3 delims={,}" %%a in ('"WMIC NICConfig where IPEnabled="True" get DefaultIPGateway /value | find "I" "') do echo IPv4 %%~a IPV6 %%~b
pause
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With