DOYENSYS Knowledge Portal




We Welcome you to visit our DOYENSYS KNOWLEDGE PORTAL : Doyensys Knowledge Portal




Thursday, September 10, 2015

Windows Server R2 - Batch Script for disk space details
----------------------------------------------------------------------------------

SETLOCAL enableextensions
(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^)^& " GB"^& " size=" ^& FormatNumber^(cdbl^(%%c^)/1024/1024/1024, 2^)^& " GB" > "%temp%\tmp.vbs"
    if not "%%c"=="" (
      echo( 
      cscript //nologo "%temp%\tmp.vbs"
      del "%temp%\tmp.vbs"
    )
  )
)

No comments: