管理员权限运行批处理连接VPN – 李志强个人博客

管理员权限运行批处理连接VPN

startvpn.bat

@echo off
%1 start mshta vbscript:CreateObject(“Shell.Application”).ShellExecute(“cmd.exe”,”/c %~dp0/vpn.bat”,””,”runas”,1)(window.close)&&exit

vpn.bat

@echo off
rasdial wt username password
for /f “tokens=2,3 delims= ” %%i in (‘”netsh int ip show addresses wt|findstr IP”‘) do set ip=%%j
if “%ip%” == “” (
echo 没有连接VPN
pause
goto :eof
)
echo %ip%

route add 172.17.0.0 mask 255.255.0.0 %ip%
route add 172.163.0.0 mask 255.255.0.0 %ip%
route add 10.39.0.0 mask 255.255.0.0 %ip%
route add 172.168.0.0 mask 255.255.0.0 %ip%
route add 192.168.0.0 mask 255.255.0.0 %ip%
route add 192.192.0.0 mask 255.255.0.0 %ip%
route add 10.68.0.0 mask 255.255.0.0 %ip%

pause

Leave a Reply

Your email address will not be published. Required fields are marked *