I'm trying to create a batch file to pull the total size and free space of the C:\ drive of servers (locally run script). I also need the output to be easily readable, so bytes is not going to work, so I'm ok with having a command line that creates a temp .vbs file.
The following seems like it could work, but the formatting/math isn't correct.
setlocal
for /f "tokens=6" %a in ('fsutil volume diskfree C: ^| find "of bytes"') do set diskspace=%a
echo wsh.echo FormatNumber(cdbl(%diskspace%)/1024, 0) > %temp%.\tmp.vbs
for /f %a in ('cscript //nologo %temp%.\tmp.vbs') do set diskspace=%a
del %temp%.\tmp.vbs
echo For example %diskspace%
The above commands are also only showing free space... I would like total size too... Wondering if the following command might be better for pulling the info:
WMIC LOGICALDISK GET Name,Size,FreeSpace | find /i "C:"
Note also that I want this to be able to be copy/pasted directly into a command prompt (not a batch file - forced requirements). I've already removed the "%%"'s from the code above.
Note: Needs to run natively on Server 2003+ (so Powershell is out, as well as any 3rd party utils).