Function Bslogin(username,password)
Set objL = CreateObject("WScript.Shell")
objL.run("chrome --app=http://10.166.250.5/termsAuth/index.htm?www.google.com/")
WScript.sleep 2000
objL.SendKeys "{TAB}"
objL.SendKeys " "
objL.SendKeys "{TAB}"
objL.SendKeys " "
WScript.sleep 1000
objL.SendKeys "^a"
objL.SendKeys username
objL.sendKeys "{TAB}"
objL.SendKeys "^a"
objL.SendKeys password
objL.SendKeys "{ENTER}"
WScript.sleep 2000
objL.SendKeys "%{F4}"
objL.sendkeys "{ESC}"
End Function
Function Ping(strHost)
Dim oPing, oRetStatus, bReturn
Set oPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address='" & strHost & "'")
For Each oRetStatus In oPing
If IsNull(oRetStatus.StatusCode) Or oRetStatus.StatusCode <> 0 Then
bReturn = False
Else
bReturn = True
End If
Set oRetStatus = Nothing
Next
Set oPing = Nothing
Ping = bReturn
End Function
username="2012LiHX"
password="xuan1624"
toping="www.google.com"
Set obj=CreateObject("WScript.shell")
hotspotname="Eq"
Dim errlvl
Do
If Not Ping(toping) Then
obj.Run "netsh wlan connect name="&hotspotname&"&setx ERL=%ERRORLEVEL%",,True
errlvl = obj.ExpandEnvironmentStrings( "%ERL%" )
obj.Run "REG delete HKCU\Environment /F /V ERL",,True
If (errorlvl=1 And Hour>=7) Then
If Not Ping("10.166.250.5") Then
obj.Run "netsh wlan connect name=wireless@bs",,True
End If
Bslogin username,password
End If
End If
WScript.sleep 900000
Loop