Answered by:
How do I retrieve hardware information from a remote machine via WMI?

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-af72d000abafFor 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.- Marked as answer by Xiaoyun Li – MSFT Wednesday, April 8, 2009 6:39 AM
Wednesday, April 8, 2009 6:37 AM
All replies
-
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-af72d000abafFor 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.- Marked as answer by Xiaoyun Li – MSFT Wednesday, April 8, 2009 6:39 AM
Wednesday, April 8, 2009 6:37 AM -
Tools related to WMI programming:
WMI Administrative Tools
http://www.microsoft.com/downloads/details.aspx?familyid=6430F853-1120-48DB-8CC5-F2ABDC3ED314&displaylang=enWMI Tools include:
WMI CIM Studio: view and edit classes, properties, qualifiers, and instances in a CIM repository; run selected methods; generate and compile MOF files.
WMI Object Browser: view objects, edit property values and qualifiers, and run methods.WMI Code Creator v1.0
http://www.microsoft.com/downloads/details.aspx?FamilyID=2cc30a64-ea15-4661-8da4-55bbc145c30e&displaylang=enThe WMI Code Creator tool allows you to generate VBScript, C#, and VB.NET code that use WMI to complete a management task such as querying for management data, executing a method from a WMI class, or receiving event notifications using 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:38 AM