Search code examples
c#wmi

disconnect ManagementScope


I'm using WMI's ManagementScope. There is a connect() method but not a disconnect one. how do i disconnect from a ManagementScope?
I tried using the "using" option but it's not IDisposable, and even if i'm out of the scope, netstat still shows me as connected.


Solution

  • looks like you should change any property of the scope and it will be disconnected:

    "A scope is disconnected after creation until someone explicitly calls Connect (), or uses the scope for any operation that requires a live connection. Also, the scope is disconnected from the previous connection whenever the identifying properties of the scope are changed."

    just as I have found here:

    System.Management - How to disconnect from remote computer?