Skip to content

Instantly share code, notes, and snippets.

@gusg21
Created December 28, 2016 15:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gusg21/4bea2df72944ad6c8b7bc9f2dd1adbb9 to your computer and use it in GitHub Desktop.
Save gusg21/4bea2df72944ad6c8b7bc9f2dd1adbb9 to your computer and use it in GitHub Desktop.
A better version of routerip.bat, a bit heavier, but with support for IPV6 and a help menu for arguments.
:: File: routerip+.bat
:: Author: gusg21
::
:: A command line tool to detect and optionally
:: open the ip address of your router.
@echo off
REM Reset ERRORLEVEL
ver > nul
REM Call argument 1 case
2>NUL CALL :c_%1
REM If nonexistent call default
IF ERRORLEVEL 1 CALL :c_def
goto :eof
:c_def
echo Unknown or no arguments provided; assuming IPV4.
echo Use '-h' for help.
:c_-4
for /f "tokens=2,3 delims={,}" %%a in ('"WMIC NICConfig where IPEnabled="True" get DefaultIPGateway /value | find "I" "') do set IPv4=%%~a && set IPV6=%%~b
echo IPV4: [ %IPV4%]
choice /M "Open this page?"
if %ERRORLEVEL% EQU 1 (
echo Opening %IPV4%...
start "" http://%IPV4%/
)
ver>nul
goto :eof
:c_-6
for /f "tokens=2,3 delims={,}" %%a in ('"WMIC NICConfig where IPEnabled="True" get DefaultIPGateway /value | find "I" "') do set IPv4=%%~a && set IPV6=%%~b
echo IPV6: [ %IPV6%]
choice /M "Open this page?"
if %ERRORLEVEL% EQU 1 (
echo Opening %IPV6%...
start "" http://[%IPV6%]/
ver>nul
)
:c_-help
:c_-h
echo Router IP Help:
echo.
echo %0 -4 : Use IPV4
echo %0 : Also IPV4
echo %0 -6 : Use IPV6
echo %0 -h : Display this
echo %0 -help : Also display this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment