1

I'm looking for a command to open the default gateway address in the browser.

This command will display the default gateway address:

ipconfig | findstr "Default Gateway"

I guess the following command should take part of the output (the address) and and define it as a variable in the following command:

start http://<address>

But I'm ignorant of the cmd syntax so I don't know how to proceed...

Thank you for your help.

1 Answer 1

1

This command store the default gateway in X variable which can be used later commands:

For /F "tokens=13 delims= " %X in ('ipconfig ^| find "Default Gateway"') do echo %X

To use this in a batch file, replace %X with %%X. In that line, the for command takes the 13th token (separated by a space) from ipconfig | find "Default Gateway" command output and stores it in X variable. The caret sign (^) is used to treat pipe symbol (|) as a normal character.

The option details can be found with for /? command. For online version, read here https://ss64.com/nt/for_cmd.html.

1
  • Thanks for your response, In summary, this will be the command: For /F "tokens=13 delims= " %X in ('ipconfig ^| find "Default Gateway"') do start http://%X
    – shraga
    Aug 2, 2019 at 13:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .