|
笔记本wmi一直出错不知道为啥换过系统也一样
+>18:52:34 开始执行 ACNWrapper v.1.0.1.7
+> ============================================
+>执行环境:
+> CPU构架: X64
+> 系统构架: X64
+> 系统语言: 0804
+> 键盘布局: 00000804
+> 内存总量: 5995MB
+> 内存剩余: 4272MB
+> 操作系统: WIN_7/Service Pack 1
+> AU3版本: 3.3.9.4
+> ============================================
>运行 AU3Check (1.54.21.0) 开始目录:D:\autoit3
+>18:52:34 AU3Check 完成[CODE]:0
$colItems = $objWMIService.ExecQuery("Select * from Win32_LogicalDiskToPartition")
$colItems = $objWMIService.ExecQuery("Select * from Win32_LogicalDiskToPartition")^ ERROR
->18:52:34 AutoIT3.exe 完成:[CODE]:1
+>18:52:35 ACNWrapper 完成..
>退出代码: 1 运行时间: 1.221 秒
代码
GetPartionMsg("", 1) ;GetPartionMsg 的第一个参数可以是 USB、IDE 等;如果不带任何参数,则是检测所有磁盘分区
;第二个参数可以是 1、0,1 表示 TRUE,0 表示 FALSE;如果第一个参数为空,则第二个必需为 1
Func GetPartionMsg($Interface, $b)
$objWMIService = ObjGet("winmgmts:\\.\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_LogicalDiskToPartition")
$DiskInfo = ""
$DiskInfoCombo = ""
For $objItem In $colItems
$DiskFH = StringLeft(StringRight($objItem.Dependent, 3), 2)
$PartNum = QueryDiskNum($DiskFH)
$PartMsg = QueryPartitionVolume($DiskFH)
If $Interface <> "" Then
If $b = 1 Then
If StringMid($PartNum, 2, 3) = $Interface Then
$DiskInfo = $DiskInfo & $PartNum & $DiskFH & $PartMsg & @CRLF
EndIf
ElseIf $b = 0 Then
If StringMid($PartNum, 2, 3) <> $Interface Then
$DiskInfo = $DiskInfo & $PartNum & $DiskFH & $PartMsg & @CRLF
EndIf
EndIf
Else
$DiskInfo = $DiskInfo & $PartNum & $DiskFH & $PartMsg & @CRLF
EndIf
Next
MsgBox(64, "磁盘信息", $DiskInfo)
EndFunc ;==>GetPartionMsg
Func QueryDiskInterface($n)
$objWMIService = ObjGet("winmgmts:\\.\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_DiskDrive Where Index=" & $n)
For $objItem In $colItems
Return $objItem.InterfaceType
Next
EndFunc ;==>QueryDiskInterface
Func QueryPartitionVolume($v)
$objWMIService = ObjGet("winmgmts:\\.\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where DeviceID='" & $v & "'")
For $objItem In $colItems
Return $objItem.VolumeName & "" & $objItem.FileSystem & "_" & CalcKMG($objItem.Size) & "_" & $objItem.Description
Next
EndFunc ;==>QueryPartitionVolume
Func QueryDiskNum($d)
$objWMIService = ObjGet("winmgmts:\\.\root\cimv2")
$colItems = $objWMIService.ExecQuery("Associators of {win32_LogicalDisk.DeviceID='" & $d & "'} where ResultClass = Win32_DiskPartition")
For $colItem In $colItems
Return "(" & QueryDiskInterface($colItem.DiskIndex) & ":hd" & $colItem.DiskIndex & ")"
Next
EndFunc ;==>QueryDiskNum
Func CalcKMG($n)
If $n < 1024 Then
Return $n & "Byte"
ElseIf $n < 1048576 Then
Return Round($n / 1024, 2) & "KB"
ElseIf $n < 1073741824 Then
Return Round($n / 1048576, 2) & "MB"
Else
Return Round($n / 1073741824, 2) & "GB"
EndIf
EndFunc ;==>CalcKMG |
|