Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. Option Explicit
  2. 'On Error Resume Next
  3.  
  4. Dim i, WshShell, argv, pingTarget, password
  5.  
  6. Set WshShell = WScript.CreateObject("WScript.Shell")
  7. Set argv = WScript.Arguments
  8. pingTarget = argv(0)
  9. password = argv(1)
  10.  
  11. 'Keep looping back through the script so that it stays running
  12. i = 0
  13. Do While i = 0
  14. If ServerPing(pingTarget) Then
  15. 'Ping was successful
  16. Else
  17. 'Ping was not successful
  18. Call ReConnectVPN(WshShell, password)
  19. End If
  20. WScript.Sleep 10000
  21. Loop
  22.  
  23. Function ReConnectVPN(WshShell, strPassword)
  24. WshShell.Run """%PROGRAMFILES(x86)%\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe"""
  25.  
  26. WScript.Sleep 1000
  27.  
  28. WshShell.AppActivate "Cisco AnyConnect Secure Mobility Client"
  29.  
  30. WshShell.SendKeys "{TAB}"
  31. WshShell.SendKeys "{TAB}"
  32. WshShell.SendKeys "{ENTER}"
  33.  
  34. WScript.Sleep 4000
  35.  
  36. WshShell.SendKeys strPassword
  37. WshShell.SendKeys "{TAB}"
  38. WshShell.SendKeys "{ENTER}"
  39.  
  40. WScript.Sleep 4000
  41.  
  42. WshShell.SendKeys "{ENTER}"
  43. End Function
  44.  
  45.  
  46.  
  47. '********************************************************************************
  48. 'ServerPing Function
  49. 'Ping the server and if available return true, otherwise false
  50. '********************************************************************************
  51. Function ServerPing(strServerName)
  52. Dim PINGFlag
  53. Set WSHShell = CreateObject("WScript.Shell")
  54. PINGFlag = Not CBool(WSHShell.Run("ping -n 5 " & strServerName, 0, True))
  55. If PINGFlag = True Then
  56. 'Ping was successful
  57. ServerPing = True
  58. Else
  59. 'Ping not successful
  60. ServerPing = False
  61. End If
  62. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement