Dim wmiService, objectsList, ObjService computerName = InputBox( "Enter PC name:" ) If computerName <> "" Then On Error Resume Next Err.Clear Set wmiService = GetObject("WinMgmts:{impersonationLevel=impersonate}!\\" &_ computerName & "\root\cimv2") If Err.Number <> 0 Then WScript.Echo "Computer not found." Err.Clear ElseIf Err.Number = 0 Then 'Check Internet connection On Error Resume Next bolActiveConnection = False Set colProcessList = wmiService.ExecQuery _ ("Select * from Win32_Process") 'Internet Connection Set wmiService = GetObject(_ "winmgmts:\\" & computerName & "\root\cimv2") Set colPings = wmiService.ExecQuery _ ("Select * From Win32_PingStatus where Address = 'google.com'") For Each objStatus in colPings If IsNull(objStatus.StatusCode) _ or objStatus.StatusCode<>0 Then bolActiveConnection = false Else bolActiveConnection = true End If Next 'Instead of displaying the output here you could do something interesting 'like If bolActiveConnection = True then do some function 'Wscript.Echo "Computer connected = " & bolActiveConnection If colProcessList.Count > 0 Then If bolActiveConnection = True Then Wscript.Echo "Pc = Turn ON Internet = ON " End If If bolActiveConnection = False Then Wscript.Echo "Pc = Turn ON Internet = OFF " End If Else If bolActiveConnection = True Then Wscript.Echo "Pc = Turn OFF Internet = ON " End If If bolActiveConnection = False Then Wscript.Echo "Pc = Turn OFF Internet = OFF " End If End If End If ElseIf computerName = "" Then WScript.Echo "You cancelled ." End If