FREEDISK (Windows Server 2003/2008/2012)

Checks to see if a specified amount of disk space is available.

      FREEDISK [/s Computer [/u [Domain\]User [/p [Password]]]] [/d Drive] [Value]
Key /s Computer The name or IP address of a remote computer (do not use backslashes). The default is the local computer. This parameter applies to all files and folders specified in the command. /u [Domain\]User Run the script with the permissions of the specified user account. The default is system permissions. /p [Password] The password of the user account that is specified in /u. /d Drive The drive for which you want to find out the availability of free space. You must specify Drive for a remote computer. Value Check for a specific amount of free disk space. specify Value in bytes, KB, MB, GB, TB, PB, EB, ZB or YB.

When used in a batch file, freedisk returns errorlevel=0 if there is enough space and errorlevel=1 if there is not enough space.

For unattended installations, you can use FREEDISK in installation batch files to check for a prerequisite amount of free space before continuing with the installation.


Determine if there is at least 500 MB of free space on drive C:

freedisk 500mb
IF %ERRORLEVEL% NEQ 0 Echo Not enough disk space!

"Our deepest fear is not that we are inadequate. Our deepest fear is that we are powerful beyond measure. It is our light, not our darkness that most frightens us. We ask ourselves, ‘Who am I to be brilliant, gorgeous, talented, fabulous?’ Actually, who are you not to be? Your playing small doesn’t serve the world" ~ Marianne Williamson

Related commands

DIRUSE - Display disk usage (2000 Resource Kit).
DirQuota - Create and manage quotas (File Server Resource Manager).
DISKUSE - Show the space used in a folder/subfolders (2003 Resource Kit).

Copyright © 1999-2024
Some rights reserved