D
Dick Kimball
I'm trying to write a script or batch file that will toggle a network
route between two possible gateway values. It needs to parse the
output of the "route print" command to get the value of the current
gateway, then toggle it to the other value.
For example, using "route print | find "1.2.3.4" I get the following:
1.2.3.4 255.255.255.0 192.168.15.1 1
In the above case, the current gateway IP is 192.168.15.1, so I would
need to change it to 192.168.16.1. If it were already set to
192.168.16.1, I would need to change it back to 192.168.15.1. So in
effect, I'm simply toggling the gateway IP back and forth between two
IP address values.
It's easy enough to do everything manually at the command prompt, but
I'd like to wrap it up in a single batch file or script.
Commands I'm looking at for this:
route print
route change
for /F
if
find
Does anyone have experience with this, or a pointer to a good
resource?
route between two possible gateway values. It needs to parse the
output of the "route print" command to get the value of the current
gateway, then toggle it to the other value.
For example, using "route print | find "1.2.3.4" I get the following:
1.2.3.4 255.255.255.0 192.168.15.1 1
In the above case, the current gateway IP is 192.168.15.1, so I would
need to change it to 192.168.16.1. If it were already set to
192.168.16.1, I would need to change it back to 192.168.15.1. So in
effect, I'm simply toggling the gateway IP back and forth between two
IP address values.
It's easy enough to do everything manually at the command prompt, but
I'd like to wrap it up in a single batch file or script.
Commands I'm looking at for this:
route print
route change
for /F
if
find
Does anyone have experience with this, or a pointer to a good
resource?