ManagementObjectSearcher Constructor (ManagementScope, ObjectQuery, EnumerationOptions)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Initializes a new instance of the ManagementObjectSearcher class to be used to invoke the specified query in the specified scope, with the specified options.

Namespace:   System.Management
Assembly:  System.Management (in System.Management.dll)

Public Sub New (
	scope As ManagementScope,
	query As ObjectQuery,
	options As EnumerationOptions


Type: System.Management.ManagementScope

A ManagementScope specifying the scope of the query.

Type: System.Management.ObjectQuery

An ObjectQuery specifying the query to be invoked.

Type: System.Management.EnumerationOptions

An EnumerationOptions specifying additional options to be used for the query.

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

The following example initializes a new instance of the ManagementObjectSearcher class with a specific query, scope, and enumeration options.

Imports System
Imports System.Management

Public Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        Dim scope As New ManagementScope("root\MyApp")
        Dim q As New SelectQuery("SELECT * FROM Win32_LogicalDisk")
        Dim o As New EnumerationOptions( _
            Nothing, System.TimeSpan.MaxValue, 1, _
            True, False, True, True, False, _
            True, True)
        Dim s As New ManagementObjectSearcher(scope, q, o)

        For Each disk As ManagementObject In s.Get()
            'show the disk instance

    End Function 'Main
End Class 'Sample

.NET Framework
Available since 1.1
Return to top