Skip to content

Instantly share code, notes, and snippets.

@theeye-io
Last active December 21, 2016 15:14
Show Gist options
  • Save theeye-io/83e24f44ce5809b94074dfb546975218 to your computer and use it in GitHub Desktop.
Save theeye-io/83e24f44ce5809b94074dfb546975218 to your computer and use it in GitHub Desktop.
checkDriveFreeSpaceWMIC.bat
rem compatible from windows version 2003. Ejemplo C:,3000000 (bytes)
@echo off
set drive=%1
shift
set threshold=%1
shift
rem woooojojojo! todo esto solo para obtener el espacio libre .
for /f "usebackq delims== tokens=2" %%x in (`wmic logicaldisk where "DeviceID='%drive%'" get FreeSpace /format:value`) do set FreeSpace=%%x
echo Free space in drive is %FreeSpace% , threshold %threshold%
IF %FreeSpace% GEQ %threshold% (
echo Free space %FreeSpace% is fine
echo success
) ELSE (
echo Free space %FreeSpace% is running low
echo failure
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment