回复 2# 502762378
谢谢502762378兄的指导,基本功能已实现,我希望检测硬盘所有分区的容量及剩余容量,由于水平有限,参考你的代码修改的数组大小和增加检测其它分区的容量(公司的电脑分区数量为1~4个),如有更好的方法请指教,谢谢!#include <file.au3>
#include <array.au3>
Local $aResult[1][1],$aRecord
$file = @ScriptDir&"\result.ini"
If Not _FileReadToArray(@ScriptDir&"\list.txt",$aRecord) Then;读取文件得到数组
MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
Exit
EndIf
For $x = 1 to $aRecord[0]
$size = 0
$DriveTypeoffnumber = 0
If Ping ($aRecord[$x],250) Then
If DriveStatus( "\"&$aRecord[$x]&"\c$" ) = "UNKNOWN" Then;有些PC可能IP冲突,也有可能没有管理员权限,暂且定义为防火墙
IniWrite($file,"info",$aRecord[$x],"Firewall")
Else
$aResult[0][0] += 1
Redim $aResult[$aResult[0][0] + 1][9]
Local $objWMIService = ObjGet("winmgmts:\" & $aRecord[$x] & "\root\CIMV2")
$colItems1 = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL")
$colItems2 = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk where Description='本地固定磁盘'", "WQL")
For $objItem1 In $colItems1
$aResult[$aResult[0][0]][0] = $aRecord[$x];电脑名
$aResult[$aResult[0][0]][1] = TCPNameToIP($aRecord[$x]);解析出的IP
$aResult[$aResult[0][0]][2] =$objItem1.UserName;登录的user
Next
For $objItem2 In $colItems2
$Size += $objItem2.Size
$DriveTypeoffnumber += $objItem2.DriveType
If $objItem2.Caption = "C:" Then
$aResult[$aResult[0][0]][5] =Round($objItem2.Size/1024/1024/1024,2) & "/" & Round($objItem2.FreeSpace/1024/1024/1024,2);C盘空间大小/及剩余空间
EndIf
If $objItem2.Caption = "D:" Then
$aResult[$aResult[0][0]][6] =Round($objItem2.Size/1024/1024/1024,2) & "/" & Round($objItem2.FreeSpace/1024/1024/1024,2);D盘空间大小/及剩余空间
EndIf
If $objItem2.Caption = "E:" Then
$aResult[$aResult[0][0]][7] =Round($objItem2.Size/1024/1024/1024,2) & "/" & Round($objItem2.FreeSpace/1024/1024/1024,2);E盘空间大小/及剩余空间
EndIf
If $objItem2.Caption = "F:" Then
$aResult[$aResult[0][0]][8] =Round($objItem2.Size/1024/1024/1024,2) & "/" & Round($objItem2.FreeSpace/1024/1024/1024,2);F盘空间大小/及剩余空间
EndIf
Next
$aResult[$aResult[0][0]][3] =Round($Size/1024/1024/1024,2);硬盘大小
$aResult[$aResult[0][0]][4] =$DriveTypeoffnumber/3;分区数量
EndIf
Else
If TCPNameToIP($aRecord[$x])<>"" Then
IniWrite($file,"info",$aRecord[$x],"No boot");没开机
Else
IniWrite($file,"info",$aRecord[$x],"N/PC");没有的PC在AD中没有即时update
EndIf
EndIf
Next
_ArrayDisplay($aResult,"")
|