The VB script dials the RAS connection "GPRS" when the connection with the name "Local Area Connection" is not connected to a network. The script does not check if this LAN connects to the internet.
Dim Shell, Hell, GPRS
Set Shell = CreateObject("WScript.Shell")
strComputer = "."
GPRS = "0"
Do
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_NetworkAdapter Where NetConnectionID = 'Local Area Connection'")
For Each objItem in colItems
If objItem.NetConnectionStatus = 7 Then
If GPRS = "0" Then
' Wscript.Echo "LAN verbinding verbroken! Status: " & objItem.NetConnectionStatus
Shell.Run ("rasdial GPRS")
GPRS = "1"
End if
Else
If GPRS = "1" Then
' Wscript.Echo "LAN verbinding actief! Status: " & objItem.NetConnectionStatus
Shell.Run ("rasdial GPRS /DISCONNECT")
GPRS = "0"
End if
End if
Next
Wscript.Sleep 10000
Loop Until Hell="Freezes over!"
No comments:
Post a Comment