Total size of drives

S

Simon

Hi

Is there a command line utility that will return
information about the total size of hard disk drives?

Thanks
Simon
 
D

Dave Patrick

This VBScript may work for you.

Dim fso, drv, tot, used, free, frmt
Set fso = CreateObject("Scripting.FileSystemObject")
Set drv = fso.GetDrive(fso.GetDriveName("D:\"))
frmt = drv.FileSystem
tot = FormatNumber(drv.TotalSize / 1073741824, 3)
free = FormatNumber(drv.FreeSpace / 1073741824, 3)
used = tot - free
msgbox "Drive " & UCase(drvPath) & " - " & drv.VolumeName & chr(10) _
& "Drive Format: " & frmt & chr(10) _
& "Total Space: " & tot & chr(10) _
& "Used Space: " & used & chr(10) _
& "Free Space: " & free
Set fso = Nothing
Set drv = Nothing

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


:
| Hi
|
| Is there a command line utility that will return
| information about the total size of hard disk drives?
|
| Thanks
| Simon
 
M

Mark V

In said:
Hi

Is there a command line utility that will return
information about the total size of hard disk drives?

Do you mean volumes ("logical drive") or the physical drive?
 
J

Jerold Schulman

The volumes - i.e. the total size of the C: drive and the
D: drive, etc.

DrvInfo.bat DriveLetter DSize FSpace Alloc
where DriveLetter is the Drive Letter,
DSize is a numeric environment variable name that will be set to the drive size
in KB.
FSpace is a numeric environment variable name that will be set to the Free
Space in KB.
Allooc is a numeric environment variable name that will be set to the
Allocation Unit (Cluster size) in bytes.

@echo off
if {%4}=={} @echo Syntax: DrvInfo DriveLetter DSize FSpace Alloc&exit /b 1
setlocal ENABLEDELAYEDEXPANSION
set work=%1
set drive=%work:~0,1%
if not exist %drive%: @echo DrvInfo: %1 does NOT exist&endlocal&exit /b 2
@echo KB total disk space.>%TEMP%\DrvInfo.tmp
@echo KB available on disk.>>%TEMP%\DrvInfo.tmp
@echo bytes in each allocation unit.>>%TEMP%\DrvInfo.tmp
set /a cnt=0
call :parse>nul 2>&1
del /q %TEMP%\DrvInfo.tmp
endlocal&set /a %2=%DSize%&set /a %3=%FSpace%&set /a %4=%Alloc%
exit /b 0
:parse
for /f "Tokens=1" %%a in ('chkdsk %drive%: /I /C^|Findstr
/G:%TEMP%\DrvInfo.tmp') do (
REM The above 2 lines are 1 line
set /a cnt=!cnt! + 1
if !cnt! EQU 1 set DSize=%%a
if !cnt! EQU 2 set FSpace=%%a
if !cnt! EQU 3 set Alloc=%%a
)


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
G

guard

Is there a command line utility that will return
information about the total size of hard disk drives?

The command ".GetFree" will return the reverse
(amount of free space) using only builtin commands.
GetFree is part of ntlib.cmd, the FREE
Advanced Command Library (http://ntlib.com).

From the GetFree Page:
1.. Displays the available free bytes on the current drive (output
adjusted)
2.. Saves the value in #Free
3.. Saves the previous value of #Free (if it exists) in #Previous_#Free
4.. Sets errorlevel based on the result
See (http://TheSystemGuard.com/MtCmds/GetValue/GetFree.htm).

*******
The Master Catalog contains over 400 resources that can
be used at the command prompt and in shell scripts in
all Windows NT/2K/XP/K3 installations using only
what is available "out of the box".
(http://TheSystemGuard.com/MasterCatalog.asp)

*******
-tsg
____________________________________________________________
TheSystemGuard.com | BoomingOrFuming.com | MountCommands.com
Free and "Almost Free" Knowledge for Windows System Admins!
 
M

Mark V

In said:
The volumes - i.e. the total size of the C: drive and the
D: drive, etc.

Jerold has posted a great method. If 3rd-party is possible,
psinfo.exe (Syinternals) can do drive summary (psinfo -d).

You'd need to extract the various drive values and add them for a
true "total" though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top