Using the /I and /C Chkdsk.exe switches,
New (Windows NT 4.0) SP4 CHKDSK switches,
I have scripted DrvInfo.bat to return a volume's size, free space, and allocation unit.
The syntax for using DrvInfo.bat is:
DrvInfo DriveLetter DSize FSpace Alloc
Where:
DriveLetter is the volume's drive letter, with or without the colon (:).
DSize is a call directed numeric environment variable that will contain the volume's size, in kilobytes (KB).
FSpace is a call directed numeric environment variable that will contain the volume's free space, in kilobytes (KB).
Alloc is a call directed numeric environment variable that will contain the volume's Allocation Unit size, in bytes.
DrvInfo.bat contains:
@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 ( set /a cnt=!cnt! + 1 call :setit!cnt! %%a ) goto :EOF :setit1 set DSize=%1 goto :EOF :setit2 set FSpace=%1 goto :EOF :setit3 set Alloc=%1
0 comments
Hide comments