scila1996 Posted March 5, 2014 Share Posted March 5, 2014 I want to test all types of Fixed partition in computer ---> Put out a message box is the largest partition? smallest partition? Link to comment Share on other sites More sharing options...
trashy Posted March 5, 2014 Share Posted March 5, 2014 Quick search and I found this and I'm a total noob. Dim $sResult $strComputer = "." $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_DiskDrive") For $objItem In $colItems $sResult &= "HDD: " & $objItem.Caption & @LF & _ @TAB & "Size: " & @LF & _ "In Byte: " & $objItem.Size & @LF & _ "In KB: " & Int($objItem.Size / 1024) & @LF & _ "In MB: " & Int($objItem.Size / 1024 ^ 2) & @LF & _ "In GB: " & Int($objItem.Size / 1024 ^ 3) & @LF & @LF Next MsgBox(0, "DiskDrive Info", $sResult) Link to comment Share on other sites More sharing options...
Malkey Posted March 5, 2014 Share Posted March 5, 2014 In AutoIt help file is found the functions DriveGetDrive and DriveSpaceTotal. #include <Array.au3> Local $Drive = DriveGetDrive('FIXED') _ArrayDisplay($Drive) Local $aDriveMax_Min[2][2] = [[$Drive[1], Round(DriveSpaceTotal($Drive[1]) / 1024, 3)], _ [$Drive[1], Round(DriveSpaceTotal($Drive[1]) / 1024, 3)]] ; $aDriveMax_Min[0][n]for Maximum; $aDriveMax_Min[1][n]for Minimum. For $i = 1 To UBound($Drive) - 1 ConsoleWrite($Drive[$i] & " " & Round(DriveSpaceTotal($Drive[$i]) / 1024, 3) & " GB" & @LF) If Round(DriveSpaceTotal($Drive[$i]) / 1024, 3) > $aDriveMax_Min[0][1] Then ; Max $aDriveMax_Min[0][1] = Round(DriveSpaceTotal($Drive[$i]) / 1024, 3) $aDriveMax_Min[0][0] = $Drive[$i] EndIf If Round(DriveSpaceTotal($Drive[$i]) / 1024, 3) < $aDriveMax_Min[1][1] Then ;Min $aDriveMax_Min[1][1] = Round(DriveSpaceTotal($Drive[$i]) / 1024, 3) $aDriveMax_Min[1][0] = $Drive[$i] EndIf Next MsgBox(0, "Results", "Largest Drive is " & StringUpper($aDriveMax_Min[0][0]) & " (" & $aDriveMax_Min[0][1] & "GB)" & @CRLF & _ "Smallest Drive is " & StringUpper($aDriveMax_Min[1][0]) & " (" & $aDriveMax_Min[1][1] & "GB)") scila1996 1 Link to comment Share on other sites More sharing options...
scila1996 Posted March 5, 2014 Author Share Posted March 5, 2014 In AutoIt help file is found the functions DriveGetDrive and DriveSpaceTotal. #include <Array.au3> Local $Drive = DriveGetDrive('FIXED') _ArrayDisplay($Drive) Local $aDriveMax_Min[2][2] = [[$Drive[1], Round(DriveSpaceTotal($Drive[1]) / 1024, 3)], _ [$Drive[1], Round(DriveSpaceTotal($Drive[1]) / 1024, 3)]] ; $aDriveMax_Min[0][n]for Maximum; $aDriveMax_Min[1][n]for Minimum. For $i = 1 To UBound($Drive) - 1 ConsoleWrite($Drive[$i] & " " & Round(DriveSpaceTotal($Drive[$i]) / 1024, 3) & " GB" & @LF) If Round(DriveSpaceTotal($Drive[$i]) / 1024, 3) > $aDriveMax_Min[0][1] Then ; Max $aDriveMax_Min[0][1] = Round(DriveSpaceTotal($Drive[$i]) / 1024, 3) $aDriveMax_Min[0][0] = $Drive[$i] EndIf If Round(DriveSpaceTotal($Drive[$i]) / 1024, 3) < $aDriveMax_Min[1][1] Then ;Min $aDriveMax_Min[1][1] = Round(DriveSpaceTotal($Drive[$i]) / 1024, 3) $aDriveMax_Min[1][0] = $Drive[$i] EndIf Next MsgBox(0, "Results", "Largest Drive is " & StringUpper($aDriveMax_Min[0][0]) & " (" & $aDriveMax_Min[0][1] & "GB)" & @CRLF & _ "Smallest Drive is " & StringUpper($aDriveMax_Min[1][0]) & " (" & $aDriveMax_Min[1][1] & "GB)") Thank You it works very well Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now