Time limit on ManagementScope.Connect?

F

federico

Hello, is there a way to limit the time a "ManagementScope.Connect"
execution takes to end before it times out by itself? I tried using
ConnectionOptions.TimeOut property to no avail.

I am trying with the code below to scan a group of computers, but there are
still a few computers that take way more than two seconds to time out.

Please, any help or pointers will be greatly appreciated.

Dim options As New ConnectionOptions
Dim query As ObjectQuery
Dim searcher As ManagementObjectSearcher
Dim queryCollection As ManagementObjectCollection
Dim m As ManagementObject
Dim scope As New ManagementScope("\\" & oName & "\root\cimv2", options)
Try
scope.Options.Timeout = New TimeSpan(20000000)
scope.Connect()
Catch ex As System.UnauthorizedAccessException
oMsg &= "Connect UnauthorizedAccessException: " & ex.Message
Exit Sub
Catch ex As System.Runtime.InteropServices.COMException
oMsg &= "Connect COMException: " & ex.Message
Exit Sub
End Try

Regards,

federico
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top