Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- cls
- echo.
- REM put your VPN connection name here
- set myvpn="Your VPN name"
- REM put your user here
- set myuser="foo"
- REM put your pass here. Leave * for asking
- set mypass="testpass"
- REM put your win admin user here
- set winadmin="administrator"
- REM put your network route here
- set network="192.168.8.0"
- REM put your network mask here
- set mask="255.255.255.0"
- REM put your gateway mask here
- set gateway="192.168.1.1"
- ipconfig | find /i %myvpn% > nul 2>&1
- if %ERRORLEVEL% == 0 (
- echo "VPN already connected. Disconnecting..."
- echo.
- rasdial %myvpn% /disconnect
- runas.exe /user:%winadmin% /savedcred "route delete %network% mask %mask% %gateway%"
- ) else if %ERRORLEVEL% == 1 (
- echo "VPN not connected. Connecting..."
- echo.
- rasdial %myvpn% %myuser% %mypass%
- runas.exe /user:%winadmin% /savedcred "route add %network% mask %mask% %gateway%"
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement