using System;using System.Management;
namespace WmiGetPhysicalMemInfo{    class Program    {        static void Main( string[] args )        {            var machineName = "..";            var userName = "...";            var pswd = "...";
 var options = new ConnectionOptions();            options.Username = userName;            options.Password = pswd;
 var queryString =                @"select * from Win32_PhysicalMemory";            var query = new ObjectQuery( queryString );
 var path = string.Format(                @"\\{0}\root\cimv2",                machineName                );
 var scope = new ManagementScope( path, options );
 var worker = new ManagementObjectSearcher( scope, query );
 var results = worker.Get();
 foreach( ManagementObject item in results )            {                Console.Write( item[ "BankLabel"]  );                Console.Write( " " );                Console.WriteLine( item[ "Capacity" ] );            }
 }    }}

Advertisements