Function fnshowprcname (prcname ){
VaR locator = new activexobject ("wbemscripting. swbemlocator ");
VaR service = locator. connectserver (".", "/root/cimv2 ");
VaR processes = service. execquery ("select * From win32_process ");
VaR processenum = new enumerator (processes );
VaR flag = false;
For (;! Processenum. atend (); processenum. movenext ()){
VaR process = processenum. Item ();
If (process. Name = prcname ){
Flag = true;
}
}
If (FLAG ){
Alert (prcname)
} Else {
Alert ('process not found ')
}
}
WMI is used to obtain the hardware and system information of the client computer:
1 // obtain system information
2 function getsysinfo (){
3 var locator = new activexobject ("wbemscripting. swbemlocator ");
4 var service = locator. connectserver (".");
5 // CPU Information
6 var CPU = new enumerator (service. execquery ("select * From win32_processor"). Item ();
7 var cputype = CPU. Name, hostname = CPU. systemname;
8 // memory information
9 var memory = new enumerator (service. execquery ("select * From win32_physicalmemory "));
10 For (VAR mem = [], I = 0 ;! Memory. atend (); memory. movenext () MEm [I ++] = {CAP: memory. item (). capacity/1024/1024, speed: memory. item (). speed}
11 // system information
12 var system = new enumerator (service. execquery ("select * From win32_computersystem"). Item ();
13 var physicmencap = math. Ceil (system. totalphysicalmemory/1024/1024), curuser = system. username, cpucount = system. numberofprocessors
14
15 return {cputype: cputype, cpucount: cpucount, hostname: Hostname, curuser: curuser, memcap: physicmencap, Mem: Mem}
16}
The code implementation mainly includes the following parts:
Access the wbemscripting object through new activexobject ("wbemscripting. swbemlocator.
Connect to our local computer through locator. connectserver (".").
Can also access other computers ).
Through service. execquery ("select * From win32_processor") This SQL-like statement (in fact, the system information is stored in a file similar to a database in the computation) gets the record set of the desired object.
Use new enumerator to create an enumerative object. You can traverse the information below.
Note: The prerequisite for running is to modify the browser security settings, "allow ActiveX attacks that are not marked as safe to be executed
Script running ".
Here we mainly take the CPU, memory, and System User information. You can use WMI APIs or jsedit to obtain
To more information. Classes of common information are listed below:
Win32_processor // CPU Processor
Win32_physicalmemory // physical memory
Win32_keyboard // keyboard
Win32_pointingdevice // enter the device, such as the mouse
Win32_diskdrive // hard drive
Win32_cdromdrive // Optical Drive
Win32_baseboard // Motherboard
Win32_bios // BIOS chip
Win32_parallelport // parallel port
Win32_serialport // serial port
Win32_sounddevice // multimedia settings
Win32_usbcontroller // USB controller
Win32_networkadapter // Network Adapter
Win32_networkadapterconfiguration // network adapter settings
Win32_printer // printer
Win32_printerconfiguration // printer settings
Win32_printjob // printer task
Win32_tcpipprinterport // printer port
Win32_potsmodem // Modem
Win32_potsmodemtoserialport // Modem Port
Win32_desktopmonitor // display
Win32_videocontroller // graphics card details.
Win32_videosettings // Display Mode Supported by the video card.
Win32_timezone // Time Zone
Win32_systemdriver // driver
Win32_diskpartition // disk partition
Win32_logicaldisk // Logical Disk
Win32_logicalmemoryconfiguration // logical memory configuration
Win32_pagefile // system page file information
Win32_pagefilesetting // page File Settings
Win32_bootconfiguration // system startup configuration
Win32_operatingsystem // operating system information
Win32_startupcommand // the system automatically starts the program.
Win32_service // system-installed Service
Win32_group // System Management Group
Win32_groupuser // system group account
Win32_useraccount // User Account
Win32_process // system process
Win32_thread // system thread
Win32_share // share
Win32_networkclient // installed network client
Win32_networkprotocol // installed network protocol
For the complete information and detailed list of WMI Win32 classes, refer to msdn:
The http://msdn2.microsoft.com/en-us/library/aa394084 (vs.85). aspx
Example:
1 function button1_onclick () {// CPU Information
2 var locator = new activexobject ("wbemscripting. swbemlocator ");
3 var service = locator. connectserver (".");
4 var properties = service. execquery ("select * From win32_processor ");
5 var E = new enumerator (properties );
6 Document. Write ("<Table border = 1> ");
7 (;! E. atend (); E. movenext ())
8 {
9 var P = E. Item ();
10 Document. Write ("<tr> ");
11 document. Write ("<TD>" + P. Caption + "</TD> ");
12 document. Write ("<TD>" + P. DeviceID + "</TD> ");
13 document. Write ("<TD>" + P. Name + "</TD> ");
14 document. Write ("<TD>" + P. cpustatus + "</TD> ");
15 Document. Write ("<TD>" + P. Availability + "</TD> ");
16 document. Write ("<TD>" + P. Level + "</TD> ");
17 document. Write ("<TD>" + P. processorid + "</TD> ");
18 document. Write ("<TD>" + P. systemname + "</TD> ");
19 document. Write ("<TD>" + P. processortype + "</TD> ");
20 document. Write ("</tr> ");
21}
22 document. Write ("</table> ");
23}
24
25 function button2_onclick () {// CD-ROM Information
26 var locator = new activexobject ("wbemscripting. swbemlocator ");
27 var service = locator. connectserver (".");
28 var properties = service. execquery ("select * From win32_cdromdrive ");
29 var E = new enumerator (properties );
30 document. Write ("<Table border = 1> ");
31 (;! E. atend (); E. movenext ())
32 {
33 var P = E. Item ();
34 Document. Write ("<tr> ");
35 document. Write ("<TD>" + P. Caption + "</TD> ");
36 document. Write ("<TD>" + P. Description + "</TD> ");
37 Document. Write ("<TD>" + P. Drive + "</TD> ");
38 document. Write ("<TD>" + P. Status + "</TD> ");
39 Document. Write ("<TD>" + P. medialoaded + "</TD> ");
40 Document. Write ("</tr> ");
41}
42 document. Write ("</table> ");
43}
44
45 function button3_onclick () {// keyboard Information
46 var locator = new activexobject ("wbemscripting. swbemlocator ");
47 var service = locator. connectserver (".");
48 var properties = service. execquery ("select * From win32_keyboard ");
49 var E = new enumerator (properties );
50 document. Write ("<Table border = 1> ");
51 (;! E. atend (); E. movenext ())
52 {
53 var P = E. Item ();
54 document. Write ("<tr> ");
55 document. Write ("<TD>" + P. Description + "</TD> ");
56 Document. Write ("<TD>" + P. Name + "</TD> ");
57 document. Write ("<TD>" + P. Status + "</TD> ");
58 document. Write ("</tr> ");
59}
60 document. Write ("</table> ");
61}
62
63 function button4_onclick () {// motherboard Information
64 var locator = new activexobject ("wbemscripting. swbemlocator ");
65 var service = locator. connectserver (".");
66 var properties = service. execquery ("select * From win32_baseboard ");
67 var E = new enumerator (properties );
68 document. Write ("<Table border = 1> ");
69 (;! E. atend (); E. movenext ())
70 {
71 var P = E. Item ();
72 document. Write ("<tr> ");
73 document. Write ("<TD>" + P. hostingboard + "</TD> ");
74 document. Write ("<TD>" + P. Manufacturer + "</TD> ");
75 document. Write ("<TD>" + P. poweredon + "</TD> ");
76 document. Write ("<TD>" + P. Product + "</TD> ");
77 document. Write ("<TD>" + P. serialnumber + "</TD> ");
78 document. Write ("<TD>" + P. Version + "</TD> ");
79 document. Write ("</tr> ");
80}
81 document. Write ("</table> ");
82}
83
84
// Obtain the local IP Address
Function getlocalipaddress (){
VaR OBJ = NULL;
VaR rslt = "";
Try
{
OBJ = new activexobject ("rcbdyctl. Setting ");
Rslt = obj. getipaddress;
OBJ = NULL;
}
Catch (E)
{
// Exception
}
// Return rslt;
Alert (rslt)
}