'部分转载
1、枚举进程
- st = "."
- set objp = GetObject("winmgmts:\\" & st)
- set objs = objp.instancesof("Win32_Process")
- for each ps in objs
- msgbox ps.name&vbcrlf&ps.processid&vbcrlf&ps.commandline
- next
复制代码
- @echo off
- rem 输出到指定文本
- wmic /output:D:\a.txt process get name,processid,commandline
- pause
复制代码
2、获取计算机名
- st = "."
- set objp = GetObject("winmgmts:\\" & st & "\root\cimv2")
- set objs = objp.execquery("select * from Win32_computersystem")
- for each ps in objs
- msgbox ps.name
- next
复制代码
- @echo off
- wmic computersystem get name
- pause
复制代码
3、检测启动项
- @echo off
- wmic startup get caption,command
- pause
复制代码
4、检查共享
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
- Set colShares = objWMIService.ExecQuery("Select * from Win32_Share")
- For each objShare in colShares
- Wscript.Echo "Name: " & objShare.Name
- Wscript.Echo "Path: " & objShare.Path
- Wscript.Echo "Type: " & objShare.Type
- Next
复制代码
- @echo off
- wmic share get name,path,type
- pause
复制代码
5、检测磁盘系统
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
- Set colDisks = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where
- DriveType = 3")
- For Each objDisk in colDisks
- Wscript.Echo "Disk drive: "& objDisk.DeviceID & " -- " & objDisk.FileSystem
- Next
复制代码
- @echo off
- wmic logicaldisk get deviceid,filesystem
- pause
复制代码
6、检测CPU
- Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
- Set colCPUs = objWMIService.InstancesOf("Win32_Processor")
- Set colCaches = objWMIService.InstancesOf("Win32_CacheMemory")
- For Each objCPU In colCPUs
- WScript.Echo "CPU设备:" & objCPU.DeviceID
- WScript.Echo "CPU名称: " & ltrim(objCPU.Name)
- WScript.Echo "接口规格:" & objCPU.SocketDesignation
- WScript.Echo "CPU电压:" & objCPU.CurrentVoltage / 10 & "V"
- WScript.Echo "主频速度:" & objCPU.CurrentClockSpeed & "MHZ"
- WScript.Echo "外频速度:" & objCPU.ExtClock & "MHZ"
- WScript.Echo "CPU缓存:"
- For Each objCache In colCaches
- Select Case objCache.Level
- case 3
- WScript.Echo chr(9) & "一级缓存大小(数据缓存+跟踪缓存):" &
- objCache.MaxCacheSize & "KB"
- case 4
- WScript.Echo chr(9) & "二级缓存大小:" & objCache.MaxCacheSize &
- "KB"
- case 5
- WScript.Echo chr(9) & "三级缓存大小:" & objCache.MaxCacheSize &
- "KB"
- End Select
- Next
- Next
复制代码
7、检测GUEST状态
- Set objNetwork = CreateObject("Wscript.Network")
- strComputer = objNetwork.ComputerName
- Set objUser = GetObject("WinNT://" & strComputer & "/Guest")
- If objUser.AccountDisabled Then
- Wscript.Echo "The Guest account is disabled."
- Else
- Wscript.Echo "The Guest account is enabled."
- End If
复制代码
8、检测电脑机型
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:" _
- & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
- Set colChassis = objWMIService.ExecQuery _
- ("Select * from Win32_SystemEnclosure")
- For Each objChassis in colChassis
- For Each strChassisType in objChassis.ChassisTypes
- Select Case strChassisType
- Case 1
- Wscript.Echo "Other"
- Case 2
- Wscript.Echo "Unknown"
- Case 3
- Wscript.Echo "Desktop"
- Case 4
- Wscript.Echo "Low Profile Desktop"
- Case 5
- Wscript.Echo "Pizza Box"
- Case 6
- Wscript.Echo "Mini Tower"
- Case 7
- Wscript.Echo "Tower"
- Case 8
- Wscript.Echo "Portable"
- Case 9
- Wscript.Echo "Laptop"
- Case 10
- Wscript.Echo "Notebook"
- Case 11
- Wscript.Echo "Handheld"
- Case 12
- Wscript.Echo "Docking Station"
- Case 13
- Wscript.Echo "All-in-One"
- Case 14
- Wscript.Echo "Sub-Notebook"
- Case 15
- Wscript.Echo "Space Saving"
- Case 16
- Wscript.Echo "Lunch Box"
- Case 17
- Wscript.Echo "Main System Chassis"
- Case 18
- Wscript.Echo "Expansion Chassis"
- Case 19
- Wscript.Echo "Sub-Chassis"
- Case 20
- Wscript.Echo "Bus Expansion Chassis"
- Case 21
- Wscript.Echo "Peripheral Chassis"
- Case 22
- Wscript.Echo "Storage Chassis"
- Case 23
- Wscript.Echo "Rack Mount Chassis"
- Case 24
- Wscript.Echo "Sealed-Case PC"
- Case Else
- Wscript.Echo "Unknown"
- End Select
- Next
- Next
复制代码
- @echo off
- wmic SystemEnclosure get ChassisTypes
- pause
复制代码
9、检测接入系统的USB设备
- st = "."
- set objp = getobject("winmgmts:\\"&st&"\root\cimv2")
- set objs = objp.execquery("select * from Win32_USBControllerDevice")
- for each p in objs
- msgbox p.Dependent
- next
复制代码
|