(view source code of srvspace.bat as plain text)
@ECHO OFF
ECHO.>CON
ECHO SrvSpace.cmd, version 1.12 for Windows NT>CON
ECHO Display free disk space per server>CON
ECHO Output is TAB delimited for redirection purposes>CON
ECHO.>CON
ECHO Written by Rob van der Woude>CON
ECHO http://www.robvanderwoude.com>CON
ECHO.>CON
:: Check for new servers
FOR /F "skip=3 eol=T tokens=1* delims=\ " %%A IN ('NET VIEW') DO CALL :AddServer %%A
:: Check all servers from server list
FOR /F "tokens=*" %%A IN ('TYPE %~dpn0.srv ^| SORT') DO CALL :Server %%A
GOTO:EOF
:AddServer
:: Check if the server list exists, add server if not
IF NOT EXIST %~dpn0.srv GOTO :Add
:: Check if server is already in server list, add server if not
TYPE %~dpn0.srv | FIND /I "%1" >NUL
IF NOT ERRORLEVEL 1 GOTO:EOF
:Add
(ECHO.%1)>>%~dpn0.srv
GOTO:EOF
:Server
:: Check drives C: through F: on each server
FOR %%a IN (C D E F) DO CALL :DiskFree %1 %%a
GOTO:EOF
:DiskFree
:: Check if this drive exists on this server
DIR \\%1\%2$ >NUL 2>NUL
IF ERRORLEVEL 1 GOTO:EOF
SETLOCAL
:: Map network drive
FOR /F "eol=T tokens=2* delims= " %%? in ('NET USE * \\%1\%2$ 2^>NUL') DO SET drive=%%?
:: Check amount of free bytes
FOR /F "tokens=1* delims= " %%? IN ('DIR /A %drive% 2^>NUL ^| FIND "bytes free"') DO SET bytes=%%?
:: Display amount of free bytes
ECHO \\%1\%2$ %bytes% bytes free
:: Disconnect network drive
NET USE %drive% /D >NUL 2>NUL
ENDLOCAL
GOTO:EOF
page last modified: 2024-04-16; loaded in 0.0045 seconds