The following script make connection with vpn server with preconfigured windows connection with ConnectionName, MyUsername and password MyP@ssw0rd . And adding static route to NetSubnet with SubnetMask :
---------------------------------------------------------------------------------------------------------
@ECHO OFF
COLOR 8F
SET NetSubnet=192.168.0.0
SET SubnetMask=255.255.255.0
ECHO.
ECHO ###########################################################
ECHO PLEASE DO NOT CLOSE THIS WINDOW
ECHO This window will automatically disappear after 20 seconds.
ECHO ###########################################################
ECHO.
ECHO Dialing VPN, please wait....
RASDial ConnectionName MyUsername MyP@ssw0rd
ECHO.
ECHO Obtaining IP Address, please wait....
PING 127.0.0.1 -n 15 -l 0 -w 0 >NUL
SET cWMIC=WMIC NICCONFIG WHERE "ServiceName='NdisWan'" GET IPAddress /FORMAT:CSV
FOR /F "tokens=2 delims=,{}" %%i IN (' %cWMIC% ^|FIND "."') DO SET IPAddress=%%i
ECHO Obtained IP address: %IPAddress%
ECHO.
ECHO Updating Routing Table, please wait....
ECHO.
ROUTE DELETE %NetSubnet% >NUL
ROUTE ADD %NetSubnet% MASK %SubnetMask% %IPAddress% METRIC 1
ROUTE PRINT %NetSubnet%
PING -n 5 -w 1 -l 1 127.0.0.1 >NUL
EXIT /B 0
---------------------------------------------------------------------------------------------------------
@ECHO OFF
COLOR 8F
SET NetSubnet=192.168.0.0
SET SubnetMask=255.255.255.0
ECHO.
ECHO ###########################################################
ECHO PLEASE DO NOT CLOSE THIS WINDOW
ECHO This window will automatically disappear after 20 seconds.
ECHO ###########################################################
ECHO.
ECHO Dialing VPN, please wait....
RASDial ConnectionName MyUsername MyP@ssw0rd
ECHO.
ECHO Obtaining IP Address, please wait....
PING 127.0.0.1 -n 15 -l 0 -w 0 >NUL
SET cWMIC=WMIC NICCONFIG WHERE "ServiceName='NdisWan'" GET IPAddress /FORMAT:CSV
FOR /F "tokens=2 delims=,{}" %%i IN (' %cWMIC% ^|FIND "."') DO SET IPAddress=%%i
ECHO Obtained IP address: %IPAddress%
ECHO.
ECHO Updating Routing Table, please wait....
ECHO.
ROUTE DELETE %NetSubnet% >NUL
ROUTE ADD %NetSubnet% MASK %SubnetMask% %IPAddress% METRIC 1
ROUTE PRINT %NetSubnet%
PING -n 5 -w 1 -l 1 127.0.0.1 >NUL
EXIT /B 0