Windows Command line get disk space in GB

I realize you're looking as VBS right now, but PowerShell can do this very easily:

$disk = Get-WmiObject Win32_LogicalDisk -Filter "DeviceID='C:'" | Select-Object Size, FreeSpace

Write-Host ("{0}GB total" -f [math]::truncate($disk.Size / 1GB))
Write-Host ("{0}GB free" -f [math]::truncate($disk.FreeSpace / 1GB))

First line gets the disk info from WMI (just does C: in this example), and selects just the Free Space and Total sizes.

In the next two lines write the Free Space and Total sizes to the console, formatted to be in GB, with fractions truncated off.

Example output (as-is):

223GB total
125GB free

Under the not a batch file - forced requirements clause, next cmd one-liner could help:

for /f "tokens=1-3" %a in ('WMIC LOGICALDISK GET FreeSpace^,Name^,Size ^|FINDSTR /I /V "Name"') do @echo wsh.echo "%b" ^& " free=" ^& FormatNumber^(cdbl^(%a^)/1024/1024/1024, 2^)^& " GiB"^& " size=" ^& FormatNumber^(cdbl^(%c^)/1024/1024/1024, 2^)^& " GiB" > %temp%\tmp.vbs & @if not "%c"=="" @echo( & @cscript //nologo %temp%\tmp.vbs & del %temp%\tmp.vbs

Output:

==>for /f "tokens=1-3" %a in ('WMIC LOGICALDISK GET FreeSpace^,Name^,Size ^|FIND
STR /I /V "Name"') do @echo wsh.echo "%b" ^& " free=" ^& FormatNumber^(cdbl^(%a^
)/1024/1024/1024, 2^)^& " GiB"^& " size=" ^& FormatNumber^(cdbl^(%c^)/1024/1024/
1024, 2^)^& " GiB" > %temp%\tmp.vbs & @if not "%c"=="" @echo( & @cscript //nolog
o %temp%\tmp.vbs & del %temp%\tmp.vbs

C: free=79,11 GiB size=111,45 GiB

D: free=929,47 GiB size=931,51 GiB

==>

Divide by 1024 to get kibytes (2^10). Divide by 1024 x 1024 to get Mibytes (2^20). Divide by 1024 x 1024 x 1024 to get Gibytes (2^30).

Windows calls these units kilobytes, Megabytes, and Gigabytes for historical reasons. I think my casing is right.

So change your sums.