daily pastebin goal
0%
SHARE
TWEET

Untitled

a guest May 31st, 2017 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Логин, для подключения к  vpn
  2. UserName = "blabla"
  3. Pass = "blabla"
  4. 'Имя подключения  vpn
  5. VPN = "Work"
  6. 'Пространство имен VPN
  7. Dim IP(1)
  8. IP(0)="192.168.142."
  9.  
  10. 'Маршруты
  11. Dim Route(3)
  12. Route(0)="172.20.20.0 mask 255.255.252.0"
  13. Route(1)="178.49.132.132 mask 255.255.255.255"
  14. Route(2)="192.168.140.0 mask 255.255.252.0"
  15.  
  16.  
  17. Set WshShell = WScript.CreateObject("WScript.Shell")
  18. Temp = WshShell.ExpandEnvironmentStrings("%TEMP%")
  19.  
  20. Set oFSO = CreateObject("Scripting.FileSystemObject")
  21. Set oTextStream = oFSO.CreateTextFile(Temp & "\rasdial_ntk.cmd", True)
  22.  
  23. Text = "@echo off" & vbCrLf & "echo Please enter the password for connection to Novotelecom" & vbCrLf & _
  24.      "rasdial " & VPN & " " & UserName & " " & Pass & " /DOMAIN:NTK" & vbCrLf & "if ErrorLevel 1 pause" & vbCrLf & _
  25.      "exit %ERRORLEVEL%"
  26.  
  27. oTextStream.Write(Text)
  28. oTextStream.Close
  29.  
  30. RetCode = WshShell.Run(Temp & "\rasdial_ntk.cmd", 1, True)
  31. If RetCode > 0 Then WScript.Quit
  32.  
  33. Set oExec = WshShell.exec("ipconfig")
  34. Do While oExec.Status = 0
  35.     WScript.Sleep 100
  36. Loop
  37.  
  38. Dim ip_s(20)
  39. i = 0
  40. n = 0
  41. tmp1 = ""
  42. tmp2 = ""
  43. tmp3 = ""
  44. Gw = ""
  45.  
  46. Do While Not oExec.StdOut.AtEndOfStream
  47.     tmp2 = tmp1
  48.     tmp1 = oExec.StdOut.Read(1)
  49.     if (isnumeric(tmp1) and isnumeric(tmp2)) or (tmp1 = "." and isnumeric(tmp2)) then i = 1
  50.     if i = 1 and tmp2 = chr(13) Then
  51.         i = 0
  52.         if len(tmp3) > 6 and len (tmp3) < 16 Then
  53.             ip_S(n) = tmp3
  54.             n = n + 1
  55.         end if
  56.         tmp3 = ""
  57.     end if
  58.     if i = 1 then tmp3 = tmp3 & tmp2
  59. loop
  60.  
  61. Set oExec = Nothing
  62.  
  63.  
  64. For m = 0 to n - 1
  65.  For k=0 to UBound(IP)-1
  66.     If (left(ip_s(m),len(IP(k)))) = IP(k) Then Gw = ip_S(m)
  67.  Next
  68. Next
  69.  
  70. RetCode = 0
  71.  
  72. If Not IsNull(Gw) Then
  73.   For k=0 to UBound(Route)-1
  74.       RetCode = WshShell.Run("route add " & Route(k) & " " & Gw, 0, True)
  75.   Next
  76. End If
  77.   If RetCode > 0 Then WScript.Echo "Error! Route add failed! Please run script under administrator."
  78. Set WshShell = Nothing
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top