Public
Class eventhandler
Class Eventhandler Public Sub handleevent () Sub Handleevent ( Byval Sender As Object , Byval E As Eventarrivedeventargs) ' Get the event object and display it Dim PD As PropertydataPD = E. newevent. properties ( " Targetinstance " ) If PD Is "" Then Else Dim MBO As ManagementbaseobjectMBO = PD. Value ' Output the properties. Console. Writeline (MBO. properties ( " Caption " ). Value MBO. properties
In yesterday's Essay: two hard disks and files related tips use APIs for obtaining the list of Hard Disk Partitions. As a reminder of the source of inspiration, WMI is used for implementation, now we have succeeded. Thanks for the ideas provided by the inspiration source.
The following is the sample code:
You must first reference System. Management. dll,
Using System. Management;SelectQuery query =
New SelectQuery ("SELECT * FROM Win32_LogicalDisk WH
A VBS that was written many years ago calls WMI to traverse the search for hard disk files and count the functions, today to tidy up the network disk, see, send up
Core code:
Function wmisfile (path_sf,justcnt) ' on Error Resume Next StrComputer = '. ' Set objWMIService = GetObject ("winmgmts:\\" StrComputer "\root\cimv2") set filelist = Objwmiservice.execquer
Y _ ("Associators of {win32_directory.name= '" Path_sf "} Where" _ "ResultClass
Set wmi=getobject ("winmgmts:\\")
Set board=wmi.instancesof ("Win32_baseboard")
For each B in board
msg= "Motherboard:" AMP;B.MANUFACTURERAMP;VBTABAMP;B.PRODUCTAMP;VBTABAMP;CHR (13)
Next
MSG=MSGAMP;CHR "---" +CHR (13)
Set cpus=wmi.instancesof ("Win32_Processor")
msg=msg "CPU Features:" +CHR (13)
For all CPU in CPUs
MSG=MSG+CPU.DEVICEIDAMP;VBTABAMP;CPU.NAMEAMP;CHR (13) _
vbtabcpu. Socketdesignationvbtabcpu. currentclockspeed "MHz" vbtabcpu.l2cachesi
1. Introduction
In WMI, you can obtain information about a disk drive by using the Win32_Processor object:ManagementClass mc = new ManagementClass ("Win32_Processor");Managementobjectcollection MOC = MC. GetInstances ();foreach (ManagementObject mo in MOC){PropertyInfo = mo. Properties[propertyname]. Value.tostring ();}
2, Properties
The property information for the Win32_Processor object is as follows:
AddresswidthArchitectureAvailabilityCaptionConf
Directory
Process start or end monitoring
Monitoring of removable disk insertion or deletion
Returned directoryProcess start or end monitoring
Code:
// Note: Reference System. Management. dll and using system. Management;
Static void
1
Using
System;
2
Using
System. Management;
3
4
Class
Sample_methoddataenumerator
5
{ 6 Public Static Int Main ( String [] ARGs) 7 { 8 Managementclass diskclass = New Managementclass (
Using System;
Using System. Collections. Generic;
Using System. IO;
Using System. LINQ;
Using System. Management;
NamespaceWmitest{ClassProgram{Static VoidMain (String[] ARGs){VaRUsbdrivenames = getallusbdrivenames ();Checkalldrivetype
Managementclass processclass = new managementclass ("win32_process ");
// Get an input parameters object for this methodManagementbaseobject inparams = processclass. getmethodparameters ("CREATE ");
// Fill in input parameter valuesInparams
#include"WMIManager.h"#include#includestring>#include#include#include/************************************************************** Technology Bloghttp://www.cnblogs.com/itdef/Technology Exchange Group number: 324164944 Welcome C C + + Windows
In fact, there are many methods to restart the VBScript of the remote restart server, such as using the SQL query analyzer.
Strcomputer
=
"
192.168.0.1"
Strusername
=
"
ABC"
Strpassword
=
"
EFG"
Set
MAC address of the NIC
Select macaddress from win32_networkadapter where (macaddress is not null) and (manufacturer <> 'Microsoft '))
Result: 08: 00: 46: 63: FF: 8C
Serial number of the CPU
Select processorid from win32_processor
Result:
I tried the asynchronous call of ManagementOperationObserver and found that RPC is unavailable. I have no time to solve this problem. Please refer to this article for instructions. Thank you.
The Code is as follows:
ConnectionOptions options = new
Copy Code code as follows:
On Error Resume Next
Set Outstreem=wscript.stdout
If (LCase right (wscript.fullname,11) = "Wscript.exe") Then
Set objshell=wscript.createobject ("Wscript.Shell")
Objshell.run ("cmd.exe/k cscript//nologo" CHR (34))
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.