I can establish VPN connection using RASDIAL command. But how do I add a route to 192.168.254.0/24 automatically after VPN is connected? Each time after VPN connection is established, Windows could assign different interface ID to the VPN connection (the IF parameter to the ROUTE command).
I can do that manually using the following method. ROUTE PRINT command shows a list of interfaces, I can write down an interface ID for the VPN (42 for example) and then issue a command
route ADD 192.168.254.0 MASK 255.255.255.0 192.168.0.200 IF 42
But how can I do this automatically in the .bat file?
I'm using PPTP VPN (it cannot automatically push routing to client).
Since interface ID is different each time VPN connects, I cannot use route -p (add a persistent route on clients). BTW, this is not a good solution, since VPN connection is sometimes used on office staff's notebooks. Sometimes their notebooks are part of the network, that is already a part of VPN and sometimes they establish VPN connection themselves.
This is a solution for PowerShell and it's ok for me. But I'm curious, can the same be done via simple .bat file?