19 gennaio 2013

how check free disk space with command dos


I will show below a simple code in order to check the free disk space with few Dos commands:


@echo off
for /f "tokens=2" %%S in ('wmic volume get DriveLetter^, FreeSpace ^| findstr "^C:"') do set freeSpace=%%S
rem if the freespace is less than 1GB then execute blat.exe to send an email 
if %freeSpace% leq 1000000000 "c:\Blat\blat.exe ...." 
@echo on
rem now, show the freespace 
@echo %freeSpace%
 
 
Remember to change the drive letter, in the example I have checked the drive C.
Regards

Nessun commento: