Rate This Content
MSDN
MSDN Library
.NET Development
.NET Framework 3.5

  Switch on low bandwidth view

We were unable to locate this content in hi-in.

Here is the same content in en-us.

This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
System.Management Namespace

Provides access to a rich set of management information and management events about the system, devices, and applications instrumented to the Windows Management Instrumentation (WMI) infrastructure. Applications and services can query for interesting management information (such as how much free space is left on the disk, what is the current CPU utilization, which database a certain application is connected to, and much more), using classes derived from ManagementObjectSearcher and ManagementQuery, or subscribe to a variety of management events using the ManagementEventWatcher class. The accessible data can be from both managed and unmanaged components in the distributed environment.

  ClassDescription
Public classCompletedEventArgs Holds event data for the Completed event.
Public classConnectionOptions Specifies all settings required to make a WMI connection.
Public classDeleteOptions Specifies options for deleting a management object.
Public classEnumerationOptions Provides a base class for query and enumeration-related options objects.
Public classEventArrivedEventArgs Holds event data for the EventArrived event.
Public classEventQuery Represents a WMI event query.
Public classEventWatcherOptions Specifies options for management event watching.
Public classInvokeMethodOptions Specifies options for invoking a management method.
Public classManagementBaseObject Contains the basic elements of a management object. It serves as a base class to more specific management object classes.
Public classManagementClass Represents a Common Information Model (CIM) management class. A management class is a WMI class such as Win32_LogicalDisk, which can represent a disk drive, and Win32_Process, which represents a process such as Notepad.exe. The members of this class enable you to access WMI data using a specific WMI class path. For more information, see "Win32 Classes" in the Windows Management Instrumentation documentation in the MSDN Library at http://msdn.microsoft.com/library.
Public classManagementDateTimeConverter Provides methods to convert DMTF datetime and time intervals to CLR-compliant DateTime and TimeSpan format and vice versa.
Public classManagementEventArgs Represents the virtual base class to hold event data for WMI events.
Public classManagementEventWatcher Subscribes to temporary event notifications based on a specified event query.
Public classManagementException Represents management exceptions.
Public classManagementNamedValueCollection Represents a collection of named values suitable for use as context information to WMI operations. The names are case-insensitive.
Public classManagementObject Represents a WMI instance.
Public classManagementObjectCollection Represents different collections of management objects retrieved through WMI. The objects in this collection are of ManagementBaseObject-derived types, including ManagementObject and ManagementClass. The collection can be the result of a WMI query executed through a ManagementObjectSearcher, or an enumeration of management objects of a specified type retrieved through a ManagementClass representing that type. In addition, this can be a collection of management objects related in a specified way to a specific management object - in this case the collection would be retrieved through a method such as GetRelated()()(). The collection can be walked using the ManagementObjectCollection..::.ManagementObjectEnumerator and objects in it can be inspected or manipulated for various management tasks.
Public classManagementObjectCollection..::.ManagementObjectEnumerator Represents the enumerator on the collection.
Public classManagementObjectSearcher Retrieves a collection of management objects based on a specified query. This class is one of the more commonly used entry points to retrieving management information. For example, it can be used to enumerate all disk drives, network adapters, processes and many more management objects on a system, or to query for all network connections that are up, services that are paused, and so on. When instantiated, an instance of this class takes as input a WMI query represented in an ObjectQuery or its derivatives, and optionally a ManagementScope representing the WMI namespace to execute the query in. It can also take additional advanced options in an EnumerationOptions. When the Get()()() method on this object is invoked, the ManagementObjectSearcher executes the given query in the specified scope and returns a collection of management objects that match the query in a ManagementObjectCollection.
Public classManagementOperationObserver Manages asynchronous operations and handles management information and events received asynchronously.
Public classManagementOptions Provides an abstract base class for all options objects.
Public classManagementPath Provides a wrapper for parsing and building paths to WMI objects.
Public classManagementQuery Provides an abstract base class for all management query objects.
Public classManagementScope Represents a scope (namespace) for management operations.
Public classMethodData Contains information about a WMI method.
Public classMethodDataCollection Represents the set of methods available in the collection.
Public classMethodDataCollection..::.MethodDataEnumerator Represents the enumerator for MethodData objects in the MethodDataCollection.
Public classObjectGetOptions Specifies options for getting a management object.
Public classObjectPutEventArgs Holds event data for the ObjectPut event.
Public classObjectQuery Represents a management query that returns instances or classes.
Public classObjectReadyEventArgs Holds event data for the ObjectReady event.
Public classProgressEventArgs Holds event data for the Progress event.
Public classPropertyData Represents information about a WMI property.
Public classPropertyDataCollection Represents the set of properties of a WMI object.
Public classPropertyDataCollection..::.PropertyDataEnumerator Represents the enumerator for PropertyData objects in the PropertyDataCollection.
Public classPutOptions Specifies options for committing management object changes.
Public classQualifierData Contains information about a WMI qualifier.
Public classQualifierDataCollection Represents a collection of QualifierData objects.
Public classQualifierDataCollection..::.QualifierDataEnumerator Represents the enumerator for QualifierData objects in the QualifierDataCollection.
Public classRelatedObjectQuery Represents a WQL ASSOCIATORS OF data query. It can be used for both instances and schema queries.
Public classRelationshipQuery Represents a WQL REFERENCES OF data query.
Public classSelectQuery Represents a WQL SELECT data query.
Public classStoppedEventArgs Holds event data for the Stopped event.
Public classWqlEventQuery Represents a WMI event query in WQL format.
Public classWqlObjectQuery Represents a WMI data query in WQL format.
  DelegateDescription
Public delegateCompletedEventHandler Represents the method that will handle the Completed event.
Public delegateEventArrivedEventHandler Represents the method that will handle the EventArrived event.
Public delegateObjectPutEventHandler Represents the method that will handle the ObjectPut event.
Public delegateObjectReadyEventHandler Represents the method that will handle the ObjectReady event.
Public delegateProgressEventHandler Represents the method that will handle the Progress event.
Public delegateStoppedEventHandler Represents the method that will handle the Stopped event.
  EnumerationDescription
Public enumerationAuthenticationLevel Describes the authentication level to be used to connect to WMI. This is used for the COM connection to WMI.
Public enumerationCimType Describes the possible CIM types for properties, qualifiers, or method parameters.
Public enumerationCodeLanguage Defines the languages supported by the code generator.
Public enumerationComparisonSettings Describes the object comparison modes that can be used with CompareTo. Note that these values may be combined.
Public enumerationImpersonationLevel Describes the impersonation level to be used to connect to WMI.
Public enumerationManagementStatus Describes the enumeration of all WMI error codes that are currently defined.
Public enumerationPutType Describes the possible effects of saving an object to WMI when using Put()()().
Public enumerationTextFormat Describes the possible text formats that can be used with GetText.
Tags What's this?: wmi (x) Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
C#: Get all Information about Remote Machine      Mahiways ... stevewallis   |   Edit   |   Show History
using System;
using System.Management;


namespace ConsoleApplication1{

    public class RemoteConnect{  

 public static void Main()  
 {      
  // Build an options object for the remote connection      
  // if you plan to connect to the remote      
  // computer with a different user name      
  // and password than the one you are currently using.      
  // This example uses the default values.             
  
  ConnectionOptions options = new ConnectionOptions();
  // Make a connection to a remote computer.      
  // Replace the "FullComputerName" section of the      
  // string "\\\\FullComputerName\\root\\cimv2" with      
  // the full computer name or IP address of the      
  // remote computer.      
  
  ManagementScope scope = new ManagementScope("\\\\localhost\\root\\cimv2", options);
  scope.Connect();
  //Query system for Operating System information      
  ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_OperatingSystem"); 
  
  // To get information about Logical Disks on Computer
  
  SelectQuery query1 = new SelectQuery("Select * from Win32_LogicalDisk");
  
        ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope,query);
  ManagementObjectCollection queryCollection = searcher.Get();
  
        ManagementObjectSearcher searcher1 = new ManagementObjectSearcher(scope,query1);
  ManagementObjectCollection queryCollection1 = searcher1.Get();

        foreach ( ManagementObject m in queryCollection)
  {          
   // Display the remote computer information
   
   Console.WriteLine("Computer Name : {0}", m["csname"]);          
   Console.WriteLine("Windows Directory : {0}", m["WindowsDirectory"]);
   Console.WriteLine("Operating System: {0}", m["Caption"]);
   Console.WriteLine("Version: {0}", m["Version"]);
   Console.WriteLine("Manufacturer : {0}", m["Manufacturer"]);
            Console.WriteLine();
  }
        foreach (ManagementObject mo in queryCollection1)
        {
            // Display Logical Disks information
      
            Console.WriteLine("              Disk Name : {0}", mo["Name"]);
            Console.WriteLine("              Disk Size : {0}", mo["Size"]);
            Console.WriteLine("          Disk DeviceID : {0}", mo["DeviceID"]);
            Console.WriteLine("         Disk DriveType : {0}", mo["DriveType"]);
            Console.WriteLine("         Disk MediaType : {0}", mo["MediaType"]);
            Console.WriteLine("              Disk Name : {0}", mo["Name"]);
            Console.WriteLine("       Disk PNPDeviceID : {0}", mo["PNPDeviceID"]);
            Console.WriteLine("      Disk ProviderName : {0}", mo["ProviderName"]);
            Console.WriteLine("        Disk VolumeName : {0}", mo["VolumeName"]);
            Console.WriteLine("        Disk SystemName : {0}", mo["SystemName"]);
            Console.WriteLine("Disk VolumeSerialNumber : {0}", mo["VolumeSerialNumber"]);
            Console.WriteLine();
        }
        
        string line;
        line = Console.ReadLine(); 
    }
  }
}

 
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker