Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
You can also try to use the option 121 of dhcp server to automatically push routes to clients? –  user132796 Aug 20 '12 at 13:16
    
Yea, but I just think, are .bat files powerful enough to do the task... –  FractalizeR Aug 20 '12 at 14:04

1 Answer 1

up vote 2 down vote accepted

I had tried to find any good working solution too and failed and after that I decided to write it by myself. You can use it if you still need it. http://www.latestbit.com/winvpnhelper

share|improve this answer
    
Miraculous!!! ;) –  FractalizeR Jan 3 '13 at 16:31
    
I hope it's working very well for you. If you have any issues please inform me. Enjoy! –  abdmob Jan 4 '13 at 17:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.