Jump to content

Test drive the largest and smallest


Recommended Posts

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

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)")
Link to comment
Share on other sites

 

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:

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...