Jump to content
Sign in to follow this  

How can i get exacly size of a Drive showed in My Computer

Recommended Posts


Hi guys i having issues to get exacly size showed in my computer, my script:

;Retorna o drive no formato D:
;$sDrive = StringLeft(@ScriptFullPath,3)
$sDrive = "F:\"

;Retorna a label do drive no formato <Sistema>
$sDriveLabel = DriveGetLabel($sDrive)

;Retorna o espaço livre do drive em megabytes como um float
$iDriveSpaceFree = DriveSpaceFree($sDrive)

;Retorna o espaço total do drive em megabytes como um float
$iDriveSpaceTotal = DriveSpaceTotal($sDrive)

;Retorna o espaço ocupado
$iDriveSpaceUsed = $iDriveSpaceTotal - $iDriveSpaceFree

; Espaço Ocupado x 100 / Espaço Total
$iPercent = ( $iDriveSpaceUsed * 100 ) / $iDriveSpaceTotal

ConsoleWrite(@CRLF & Round($iDriveSpaceFree / 1024,2) & " GB livre(s) de " & Round($iDriveSpaceTotal / 1024,2) & " GB" & @CRLF)


With the same script i get a wrong a correct results


In my computer:

92,0 / 98,9

In AutoIt:

92.01 / 98.95



In my computer:

7,28 / 7,91

In AutoIt:

7.28 / 7.91


thanks in advance

Share this post

Link to post
Share on other sites

It seems to me that windows is rounding these numbers to three significant figures and you are rounding to two decimal places. That could possibly produce this degree of variance.

Edited by czardas

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.