Dim shl, exec, tmp1, tmp2, tmp3, tmp4
Dim fsob, fl, shl2, exec2, drob1, sdr
Dim ip1, ip2, local_ip, global_ip
Dim sw
Set shl = CreateObject("WScript.Shell")
Set exec = shl.Exec("ipconfig.exe")
local_ip = ""
global_ip = ""
Do While Not exec.StdOut.AtEndOfStream
tmp1 = exec.StdOut.Read(1)
if isnumeric(tmp1) or (tmp3 = "." and isnumeric(tmp4)) then
tmp2 = tmp2 & tmp1
end if
tmp4 = tmp3
tmp3 = tmp1
if tmp3 = "." and isnumeric(tmp4) then
tmp2 = tmp2 & tmp1
end if
if tmp2 <> "" and tmp1 = chr(13) then
tmp4 = left(tmp2, 6)
if tmp4 = "77.79." or tmp4 = "92.50." or tmp4 = "81.30." or tmp4 = "89.189" or tmp4 = "172.27" or tmp4 = "94.41." or tmp4 = "172.25" then
if ip1 = "" then
ip1 = tmp2:tmp2 = ""
end if
if ip2 = "" and ip1 <> "" then
ip2 = tmp2:tmp2 = ""
if ip1 = ip2 then
ip1 = ""
end if
end if
else
tmp2 = ""
end if
end if
Loop
if left(ip1, 6) = "172.25" and (left(ip2, 6) = "77.79." or left(ip2, 6) = "92.50." or left(ip2, 6) = "81.30." or left(ip2, 6) = "89.189" or left(ip2, 6) = "94.41") then
msgbox "Недостаточно средств на счете.", vbInformation
sw = 1
end if
if left(ip1, 6) = "172.25" and left(ip2, 6) = "172.27" then
msgbox "Недостаточно средств на безлимитном договоре." & chr(13) & "Будут доступны только локальные ресурсы.", vbInformation
end if
if left(ip2, 6) = "172.25" and (left(ip1, 6) = "77.79." or left(ip2, 6) = "92.50." or left(ip2, 6) = "81.30." or left(ip2, 6) = "89.189" or left(ip2, 6) = "94.41") then
msgbox "Недостаточно средств на счете.", vbInformation
sw = 1
end if
if left(ip2, 6) = "172.25" and left(ip1, 6) = "172.27" then
msgbox "Недостаточно средств на безлимитном договоре." & chr(13) & "Будут доступны только локальные ресурсы.", vbInformation
end if
if left(ip1, 6) = "172.27" and ip2 <> "" then
local_ip = ip1
global_ip = ip2
else
if left(ip2, 6) = "172.27" and ip1 <> "" then
local_ip = ip2
global_ip = ip1
end if
end if
if local_ip = "" then
msgbox "Найдено только одно VPN подключение." & Chr(13) & "Установите два подключения (@local и анлим).", vbInformation
sw = 1
end if
Set drob1 = CreateObject("WScript.Shell")
sdr = drob1.ExpandEnvironmentStrings("%WinDir%")
if sw <> 1 then
'msgbox "88.204.127.86: " & global_ip & chr(13) & "95.170.126.43: " & local_ip
Set fsob = CreateObject("Scripting.FileSystemObject")
Set fl = fsob.CreateTextFile(sdr & "\routing.bat", True)
fl.WriteLine "route delete 0.0.0.0"
fl.WriteLine "route add 0.0.0.0 mask 0.0.0.0 " & global_ip & " metric 3"
fl.WriteLine "route add 172.16.0.0 mask 255.240.0.0 " & local_ip & " metric 2"
fl.WriteLine "route add 81.30.176.0 mask 255.255.240.0 " & local_ip & " metric 2"
fl.WriteLine "route add 172.25.0.0 mask 255.255.0.0 " & local_ip & " metric 2"
fl.WriteLine "route add 81.30.192.0 mask 255.255.224.0 " & local_ip & " metric 2"
fl.WriteLine "route add 89.189.128.0 mask 255.255.224.0 " & local_ip & " metric 2"
fl.WriteLine "route add 77.79.128.0 mask 255.255.192.0 " & local_ip & " metric 2"
fl.WriteLine "route add 92.50.128.0 mask 255.255.192.0 " & local_ip & " metric 2"
fl.WriteLine "route add 10.0.0.0 mask 255.0.0.0 " & local_ip & " metric 1"
fl.WriteLine "route add 193.84.31.5 mask 255.255.255.255 " & local_ip & " metric 1"
fl.WriteLine "route add 94.41.0.0 mask 255.255.0.0 " & local_ip & " metric 1"
fl.WriteLine "route add 92.50.168.0 mask 255.255.248.0 " & local_ip & " metric 1"
fl.WriteLine "route add 81.30.199.50 mask 255.255.255.255 " & global_ip & " metric 1"
fl.WriteLine "route add 81.30.199.69 mask 255.255.255.255 " & global_ip & " metric 1"
fl.WriteLine "route add 81.30.199.70 mask 255.255.255.255 " & global_ip & " metric 1"
fl.WriteLine "route add 81.30.197.10 mask 255.255.255.255 " & global_ip & " metric 1"
fl.WriteLine "route add 81.30.199.84 mask 255.255.255.255 " & global_ip & " metric 1"
'fl.WriteLine "pause"
fl.Close
Set shl2 = CreateObject("WScript.Shell")
shl2.Run (sdr & "/routing.bat")
end if