title: How to make a script that adds a network route?
body: <p>Scenario</p>
  <p>SO Windows 7</p>
  <p>I need to connect to remote host via cisco VPN. Sometimes the host destination network is the same of local network.
  Example (Partial output of ipconfig command):</p>
  <pre>
  Ethernet adapter Cisco Vpn Adapter:
     IPv4 Address. . . . . . . . . . . : 192.168.100.12
     Subnet Mask . . . . . . . . . . . : 255.255.255.0
  
  Wireless LAN adapter Wireless Network Connection:
     IPv4 Address. . . . . . . . . . . : 192.168.1.74
     Subnet Mask . . . . . . . . . . . : 255.255.255.0
  </pre>
  <p>I need to connect to host 192.168.1.11 on the remote network via Vpn
  Then I need to add new route (in this configuration all traffic to 192.168.1.xxx are route to local network)
  The output of route print begining by:</p>
  <pre>Interface List
   17...00 05 9a 3c 78 00 ......Cisco Systems VPN Adapter
   12...00 16 44 ea 74 58 ......Dell Wireless 1395 WLAN Mini-Card</pre>
  <p>And the command is:<br/>
  <code>route add 192.168.1.11 mask 255.255.255.255 192.168.100.12 metric 1 if 17</code>
  <br/></p>
  <p>Problem:<br />
  The Ip on Cisco adapter is not static, i can't route add with modifier -p (permanent) When disconected and reconnect I need  look for the NewIp and add the correct route:<br />
  <code>route add 192.168.1.11 mask 255.255.255.255 «NewIP» metric 1 if 17</code>
  <br/>
  For me its easy (but boring) write all this commmands every time:</p>
  <pre>ipconfig  etc
  route print etc
  route add etc
  </pre>
  <p>I need a bat or PowerShell script to add the correct route. The scrip look for the IP on the Cisco adapter and run the command route add with IP gateway founded.</p>
  <p>Thanks</p>