Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15189

[RESOLVED] ManagementObjectCollection on PC shutdown

$
0
0
Hi.
I'm using a ManagementObjectCollection object.
My issue is that when a remote PC I'm monitoring shuts down, the ManagementObjectCollection will not function anymore.
To explain further, if I do this:

Code:

  Dim mok3 As ManagementObjectCollection
                              Try
                                  mok3 = searcher3.Get()
.....

'And here the PC has shut down:

Try

        For Each mo As System.Management.ManagementObject In mok3

''' goes to Catch

mok3 will go to a timeout state if the PC shuts down
So is there a way to maintain the mok3 until the end of the for loop or I can only use try catch?

I saw a copyto method but using it will always result out of range:

Code:

  Dim mok3 As ManagementObjectCollection
  Try
 mok3 = searcher3.Get()

 Dim varArray As Array = varArray.CreateInstance(mok3.[GetType](), mok3.Count)
 mok3.CopyTo(varArray,  mok3.Coun)

 Catch ex As Exception
                               
End Try

Thanks.

Viewing all articles
Browse latest Browse all 15189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>