Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Логин, для подключения к vpn
- UserName = "blabla"
- Pass = "blabla"
- 'Имя подключения vpn
- VPN = "Work"
- 'Пространство имен VPN
- Dim IP(1)
- IP(0)="192.168.142."
- 'Маршруты
- Dim Route(3)
- Route(0)="172.20.20.0 mask 255.255.252.0"
- Route(1)="178.49.132.132 mask 255.255.255.255"
- Route(2)="192.168.140.0 mask 255.255.252.0"
- Set WshShell = WScript.CreateObject("WScript.Shell")
- Temp = WshShell.ExpandEnvironmentStrings("%TEMP%")
- Set oFSO = CreateObject("Scripting.FileSystemObject")
- Set oTextStream = oFSO.CreateTextFile(Temp & "\rasdial_ntk.cmd", True)
- Text = "@echo off" & vbCrLf & "echo Please enter the password for connection to Novotelecom" & vbCrLf & _
- "rasdial " & VPN & " " & UserName & " " & Pass & " /DOMAIN:NTK" & vbCrLf & "if ErrorLevel 1 pause" & vbCrLf & _
- "exit %ERRORLEVEL%"
- oTextStream.Write(Text)
- oTextStream.Close
- RetCode = WshShell.Run(Temp & "\rasdial_ntk.cmd", 1, True)
- If RetCode > 0 Then WScript.Quit
- Set oExec = WshShell.exec("ipconfig")
- Do While oExec.Status = 0
- WScript.Sleep 100
- Loop
- Dim ip_s(20)
- i = 0
- n = 0
- tmp1 = ""
- tmp2 = ""
- tmp3 = ""
- Gw = ""
- Do While Not oExec.StdOut.AtEndOfStream
- tmp2 = tmp1
- tmp1 = oExec.StdOut.Read(1)
- if (isnumeric(tmp1) and isnumeric(tmp2)) or (tmp1 = "." and isnumeric(tmp2)) then i = 1
- if i = 1 and tmp2 = chr(13) Then
- i = 0
- if len(tmp3) > 6 and len (tmp3) < 16 Then
- ip_S(n) = tmp3
- n = n + 1
- end if
- tmp3 = ""
- end if
- if i = 1 then tmp3 = tmp3 & tmp2
- loop
- Set oExec = Nothing
- For m = 0 to n - 1
- For k=0 to UBound(IP)-1
- If (left(ip_s(m),len(IP(k)))) = IP(k) Then Gw = ip_S(m)
- Next
- Next
- RetCode = 0
- If Not IsNull(Gw) Then
- For k=0 to UBound(Route)-1
- RetCode = WshShell.Run("route add " & Route(k) & " " & Gw, 0, True)
- Next
- End If
- If RetCode > 0 Then WScript.Echo "Error! Route add failed! Please run script under administrator."
- Set WshShell = Nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement