????1??  ??????????????System.Management.dll
????2??  ?????? ??ManagementScope
???????????????????????
1 private const string PROPERTY_CAPACITY = "Capacity";
2         private const string PROPERTY_AVAILABLE_BYTES = "AvailableBytes";
3         private const string PROPERTY_PROCESS_ID = "ProcessId";
4         private const string PROPERTY_PROCESS_NAME = "Name";
5         private const string PROPERTY_WORKING_SET_SIZE = "WorkingSetSize";
6
7
8 ConnectionOptions Conn = new ConnectionOptions();
9                 //?趨????WMI??????????????
10                 Conn.Username = "?????";
11                 //?趨????????
12                 Conn.Password = "????";
13              ManagementScope   Ms = new         ManagementScope("\\ip\root\cimv2"?? Conn);
14                 Ms.Connect();
????????????????
1 var query1 = new SelectQuery("SELECT * FROM Win32_PhysicalMemory");
2  var query2 = new SelectQuery("SELECT * FROM Win32_PerfRawData_PerfOS_Memory");
3   var query3 = new SelectQuery("SELECT * FROM Win32_Processor");
4  var query4 = new SelectQuery("SELECT * FROM Win32_Process");
5
6  var searcher1 = new ManagementObjectSearcher(Ms?? query1);
7  var searcher2 = new ManagementObjectSearcher(Ms?? query2);
8 var searcher3 = new ManagementObjectSearcher(Ms?? query3);
9 var searcher4 = new ManagementObjectSearcher(Ms?? query4);
???????????CPU??
1 var capacity = 0.0;
2    var free = 0.0;
3   var cpu = 0.0;
4  // 2048
5    foreach (var o in searcher1.Get())
6capacity += (double)Convert.ToUInt64(o[PROPERTY_CAPACITY]) / (double)(1024 * 1024);
7                         foreach (var o in searcher2.Get())
8                             free += (double)Convert.ToUInt64(o[PROPERTY_AVAILABLE_BYTES]) / (double)(1024 * 1024);
9                         foreach (var o in searcher3.Get())
10                         {
11                             if (o["LoadPercentage"] != null)
12                             {
13                                 cpu = long.Parse(o["LoadPercentage"].ToString());
14                             }
15                             else {
16                                 cpu = 0;
17                             }
18                         }
????????????????????????????????????
1 ConnectionOptions Conn = new ConnectionOptions();
2             Conn.Username = userName; //?趨????????
3             Conn.Password = pwd;
4             Ms = new ManagementScope("\\" + ip + "\root\cimv2"?? Conn);
5             Ms.Connect();
6  ManagementClass processClass = new ManagementClass(Ms?? new ManagementPath("Win32_Process")?? null);
7             //??????????????????
8             ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
9             //?趨?????в???
10                 inParams["CommandLine"] = path;// @"???????????·??";
11                 //??г???
12             ManagementBaseObject outParams = processClass.InvokeMethod("Create"?? inParams?? null);
????Other???????ó???????????????(.bat)????????????????????
?????????????н??? ??tasklist /S ip /U ????? /P ????
???????????????
????taskkill  /S ip /U?????/P ????  /IM ????????????