Jump to content
Sign in to follow this  
scila1996

Test drive the largest and smallest

Recommended Posts

scila1996
I want to test all types of Fixed partition in computer 
 
---> Put out a message box 
 
is the largest partition? 
smallest partition?
 
 

Share this post


Link to post
Share on other sites
trashy

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)

Share this post


Link to post
Share on other sites
Malkey

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)")
  • Like 1

Share this post


Link to post
Share on other sites
scila1996

 

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  :thumbsup:

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×