马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 st788796 于 2017-6-9 16:02 编辑
strComputer = "." Set objWMIService =GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer_ & "\root\cimv2") Set colDiskDrives = objWMIService.ExecQuery_ ("Select * from Win32_DiskDrive") For each objDiskDrive in colDiskDrives Wscript.Echo "Bytes Per Sector: " & vbTab & _ objDiskDrive.BytesPerSector For i = Lbound(objDiskDrive.Capabilities) to _ Ubound(objDiskDrive.Capabilities) Wscript.Echo "Capabilities: " & vbTab & _ objDiskDrive.Capabilities(i) Next Wscript.Echo "Caption: " & vbTab & objDiskDrive.Caption Wscript.Echo "Device ID: " & vbTab & objDiskDrive.DeviceID Wscript.Echo "Index: " & vbTab & objDiskDrive.Index Wscript.Echo "Interface Type: " & vbTab &objDiskDrive.InterfaceType Wscript.Echo "Manufacturer: " & vbTab &objDiskDrive.Manufacturer Wscript.Echo "Media Loaded: " & vbTab & objDiskDrive.MediaLoaded Wscript.Echo "Media Type: " & vbTab & objDiskDrive.MediaType Wscript.Echo "Model: " & vbTab & objDiskDrive.Model Wscript.Echo "Name: " & vbTab & objDiskDrive.Name Wscript.Echo "Partitions: " & vbTab &objDiskDrive.Partitions Wscript.Echo "PNP DeviceID: " & vbTab & objDiskDrive.PNPDeviceID Wscript.Echo "SCSI Bus: " & vbTab & objDiskDrive.SCSIBus Wscript.Echo "SCSI Logical Unit: " & vbTab & _ objDiskDrive.SCSILogicalUnit Wscript.Echo "SCSI Port: " & vbTab & objDiskDrive.SCSIPort Wscript.Echo "SCSI TargetId: " & vbTab & objDiskDrive.SCSITargetId Wscript.Echo "Sectors Per Track: " & vbTab & _ objDiskDrive.SectorsPerTrack Wscript.Echo "Signature: " & vbTab & objDiskDrive.Signature Wscript.Echo "Size: " & vbTab & objDiskDrive.Size Wscript.Echo "Status: " & vbTab & objDiskDrive.Status Wscript.Echo "Total Cylinders: " & vbTab & _ objDiskDrive.TotalCylinders Wscript.Echo "Total Heads: " & vbTab & objDiskDrive.TotalHeads Wscript.Echo "Total Sectors: " & vbTab & objDiskDrive.TotalSectors Wscript.Echo "Total Tracks: " & vbTab & objDiskDrive.TotalTracks Wscript.Echo "Tracks Per Cylinder: " & vbTab & _ objDiskDrive.TracksPerCylinder Next
以上代码是读取物理磁盘信息的,非分区信息。。
接下来来个读取光驱的。配合限制来计算注册码很方便。呵呵!!
On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:\\"& strComputer & "\root\cimv2") Set colItems =objWMIService.ExecQuery("Select * from Win32_CDROMDrive") For Each objItem in colItems Wscript.Echo "Availability: " & objItem.Availability For Each strCapability in objItem.Capabilities Wscript.Echo "Capability: "& strCapability Next Wscript.Echo "Caption: " & objItem.Caption Wscript.Echo "Description: " & objItem.Description Wscript.Echo "Device ID: " & objItem.DeviceID Wscript.Echo "Drive: " & objItem.Drive Wscript.Echo "Manufacturer: " & objItem.Manufacturer Wscript.Echo "Media Loaded: " & objItem.MediaLoaded Wscript.Echo "Media Type: " & objItem.MediaType Wscript.Echo "Name: " & objItem.Name Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID Wscript.Echo "SCSI Bus: " & objItem.SCSIBus Wscript.Echo "SCSI Logical Unit: " &objItem.SCSILogicalUnit Wscript.Echo "SCSI Port: " & objItem.SCSIPort Wscript.Echo "SCSI Target ID: " & objItem.SCSITargetId Next
接着是能读取 显示设备 显卡 驱动等信息的代码
On Error Resume Next strComputer = "." Set objWMIService =GetObject("winmgmts:\\" & strComputer &"\root\cimv2") Set colItems =objWMIService.ExecQuery("Select * from Win32_DisplayConfiguration") For Each objItem in colItems Wscript.Echo "Bits Per Pel: " & objItem.BitsPerPel Wscript.Echo "Device Name: " & objItem.DeviceName
Wscript.Echo "Display Flags: " & objItem.DisplayFlags Wscript.Echo "Display Frequency: " &objItem.DisplayFrequency Wscript.Echo "Driver Version: " & objItem.DriverVersion Wscript.Echo "Log Pixels: " & objItem.LogPixels Wscript.Echo "Pels Height: " & objItem.PelsHeight Wscript.Echo "Pels Width: " & objItem.PelsWidth Wscript.Echo "Setting ID: " & objItem.SettingID Wscript.Echo "Specification Version: " &objItem.SpecificationVersion Wscript.Echo Next
再来读取内存信息的
On Error Resume Next strComputer = "." Set objWMIService =GetObject("winmgmts:\\" & strComputer &"\root\cimv2") Set colItems =objWMIService.ExecQuery("Select * from Win32_MemoryArray") For Each objItem in colItems Wscript.Echo "Device ID: " & objItem.DeviceID Wscript.Echo "Ending Address: " & objItem.EndingAddress Wscript.Echo "Starting Address: " &objItem.StartingAddress Wscript.Echo Next
继续上个读取 系统信息的代码
strComputer = "." Set objWMIService =GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer& "\root\cimv2") Set colSettings = objWMIService.ExecQuery _ ("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colSettings Wscript.Echo "OS Name: " & objOperatingSystem.Name
Wscript.Echo "Version: " & objOperatingSystem.Version Wscript.Echo "Service Pack: " & _ objOperatingSystem.ServicePackMajorVersion _ & "." & objOperatingSystem.ServicePackMinorVersion Wscript.Echo "OS Manufacturer: " &objOperatingSystem.Manufacturer Wscript.Echo "Windows Directory: " & _ objOperatingSystem.WindowsDirectory Wscript.Echo "Locale: " & objOperatingSystem.Locale Wscript.Echo "Available Physical Memory: " & _ objOperatingSystem.FreePhysicalMemory Wscript.Echo "Total Virtual Memory: " & _ objOperatingSystem.TotalVirtualMemorySize Wscript.Echo "Available Virtual Memory: " & _ objOperatingSystem.FreeVirtualMemory Wscript.Echo "OS Name: " &objOperatingSystem.SizeStoredInPagingFiles Next
Set colSettings = objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem") For Each objComputer in colSettings Wscript.Echo "System Name: " & objComputer.Name Wscript.Echo "System Manufacturer: " &objComputer.Manufacturer Wscript.Echo "System Model: " & objComputer.Model Wscript.Echo "Time Zone: " & objComputer.CurrentTimeZone Wscript.Echo "Total Physical Memory: " & _ objComputer.TotalPhysicalMemory Next
Set colSettings = objWMIService.ExecQuery _ ("Select * from Win32_Processor") For Each objProcessor in colSettings Wscript.Echo "System Type: " & objProcessor.Architecture Wscript.Echo"Processor: " & objProcessor.Description Next
Set colSettings = objWMIService.ExecQuery _ ("Select * from Win32_BIOS") For Each objBIOS in colSettings Wscript.Echo "BIOS Version: " & objBIOS.Version
'本脚本的功能是检测硬件的信息。
On Error Resume Next temp=0 setwshshell=wscript.createobject("wscript.shell") '启动WMI服务 wshshell.run ("%comspec% /c regsvr32/s scrrun.dll"),0,True wshshell.run ("%comspec% /c sc configwinmgmt start= auto"),0,True wshshell.run ("%comspec% /c net startwinmgmt"),0
strComputer = "." Set objWMIService =Getobject("winmgmts:\\" & strComputer &"\root\cimv2")
'用一个文本来记录硬件信息
Set WshNetwork =WScript.Createobject("WScript.Network") computername=WshNetwork.ComputerName
setfso=createobject("scripting.filesystemobject") tempfilter=("\\192.168.1.5\共享文件\Computer\"&computername &".txt") set tempfile=fso.createtextfile(tempfilter)
'主板
set board=objwmiservice.execQuery("select * from win32_baseboard") for each item in board board2="主板: " &item.Product next tempfile.writeline(board2)
'CPU
set cpu=objwmiservice.execQuery("select * from win32_processor") for each item in cpu cpu2= "CPU : " & item.Name next tempfile.writeline(cpu2)
'内存
Set colItems = objWMIService.ExecQuery("Select* from Win32_PhysicalMemory",,48) For Each objItem in colItems a=objitem.capacity/1048576 temp=temp+objitem.capacity n=n+1 Next memory=temp/1048576 if n=1 then memory2= "内存: "& n & "条" &a&"M" else memory2= "内存: "& n & "条" &a&"M"&" 总计"&memory&"M" end if tempfile.writeline(memory2)
'硬盘
set disk=objwmiservice.execQuery("select * from win32_diskdrive") for each item in disk disk2= disk2 & item.model &"" disk1= "硬盘: " next tempfile.write(disk1) tempfile.writeline(disk2)
'显卡
set video=objwmiservice.execQuery("select * from win32_videocontroller",,48) for each item in video video2= "显卡: "& item.Description next
tempfile.writeline(video2)
'网卡
set network=objwmiservice.execQuery("SELECT * FROM Win32_NetworkAdapterConfigurationWHERE IPEnabled = True") for each item in network lan="网卡: " &item.description next tempfile.writeline(lan)
systeminfo2="时间: "& now tempfile.writeline(systeminfo2) |