locked
How do I retrieve hardware information from a remote machine via WMI? RRS feed

  • Question

  • How do I retrieve hardware information from a remote machine via WMI?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, April 8, 2009 6:37 AM

Answers

  • Firstly, remote connections in WMI are affected by the Windows Firewall and DCOM settings.  In Windows Vista and later operation systems, User Account Control (UAC) may also require changes to certain settings.   For more details, please see Connecting to WMI Remotely Starting with Vista.

    Windows Firewall settings must be configured to allow the remote connection.   However, Windows Firewall does not support any remote configuration.   The configuration must be done locally on the target machine either by changing the Group Policy settings, by executing NETSH commands, or executing a script locally.  For more information, please check Connecting Through Windows Firewall.

    In addition, correct DCOM settings and WMI namespace security settings are also really important for a remote WMI connection.   To configure DCOM settings, we can use the DCOM Config utility (DCOMCnfg.exe) found in Administrative Tools in Control Panel.  By default, a specific WMI namespace permission is enabled only for administrators.   An administrator can enable remote access to specific WMI namespace for a non-administrator user.   For more information on DCOM settings and WMI namespace security settings, please refer to Securing a Remote WMI Connection.

    After modifying these settings, we can retrieve the information from a remote computer via WMI in C#.   System.Management.dll should be added into the project first.   Then we use ConnectionOptions and ManagementScope to make the connection to the remote computer.  

    For a detailed code sample, please refer to How To: Connect to a Remote Computer, for both Visual C# and Visual Basic versions. 

     

    Related thread:
    http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/5a4eb048-e013-49a6-b827-af72d000abaf

     

    For more FAQ about Visual C# General, please see Visual C# General FAQ

     



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, April 8, 2009 6:37 AM

All replies