I posted a code snippet earlier today. The code below grabs the operating system of a remote computer:
Code:
Private Sub cmdCheckStatus_Click() Dim strComputer As String Dim objWMIService As Object
Dim colItems As Object
Dim objItem As Object
strComputer = Me.txtMachine.Value
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery( _
"Select * from Win32_OperatingSystem", , 48)
For Each objItem In colItems
CompName = Nz(objItem.Name, 0)
Next
PipePosition = InStr(1, CompName, "|")
CompName = Left(CompName, PipePosition - 1)
Me.txtCheckStatus.Value = CompName
Set objItem = Nothing
Set colItems = Nothing
Set objWMIService = Nothing End Sub
My issue is that i get an error if the host can't be reached. Is there any way to supress the error?