Windows Batch File Check Disk Space

Posted on by admin

Freedisk. 2 minutes to read.In this articleApplies To: Windows Server (Semi-Annual Channel), Windows Server 2016, Windows Server 2012 R2, Windows Server 2012Checks to see if the specified amount of disk space is available before continuing with an installation process. Syntax freedisk /s /u /p /d Parameters ParameterDescription/sSpecifies the name or IP address of a remote computer (do not use backslashes).

  1. How To Check Hard Disk Size In Command Prompt

The default is the local computer. This parameter applies to all files and folders specified in the command./u Runs the script with the permissions of the specified user account. The default is system permissions./p Specifies the password of the user account that is specified in /u./dSpecifies the drive for which you want to find out the availability of free space. You must specify for a remote computer.Checks for a specific amount of free disk space. You can specify in bytes, KB, MB, GB, TB, PB, EB, ZB or YB.Remarks. Using the /s, /u, and /p command-line options are available only when you use /s. You must use /p with /uto provide the user s password.

for unattended installations, you can use freedisk in installation batch files to check for the prerequisite amount free space before continuing with the installation. When you use freedisk in a batch file, it returns a 0 if there is enough space and a 1 if there is not enough space. ExamplesTo determine whether there are at least 50 MB of free space available on drive C:, type:freedisk 50mbOutput similar to the following appears on the screen:INFO: The specified 52,428,800 byte(s) of free space is available on current drive.additional referencesRecommended Content.

I need to get the mail alert for disk space details. I have found this script in our forum. When I run this script in command prompt, it generates the output as mentioned below. But when I run this by saving it as a batch file, it doesn't work.Can any one help me how to make this as a batch file or any other method to get the disk space details using batch file, so that I could schedule in Task Scheduler.

Windows Batch File Check Disk Space

How To Check Hard Disk Size In Command Prompt

Script(for /f 'tokens=1-3'%a in ('WMIC LOGICALDISK GET FreeSpace^,Name^,Size ^ FINDSTR /I /V 'Name') do @echo wsh.echo '%b' ^& ' free=' ^& FormatNumber^(cdbl^(%a^)/1024/1024/1024, 2^)^& ' GB'^& ' size=' ^& FormatNumber^(cdbl^(%c^)/1024/1024/1024, 2^)^& ' GB' %temp%tmp.vbs & @if not '%c' @echo( & @cscript //nologo%temp%tmp.vbs & del%temp%tmp.vbs) E:monitoringscriptslogDiskstatus.txt OutputC: free=79,11 GiB size=111,45 GiBD: free=929,47 GiB size=931,51 GiB. Hi Josef, I have tried like this. Am I doing it write. (for /F 'usebackq tokens=3 delims'%%G in (' WMIC LOGICALDISK GET FreeSpace^,Name^,Size ^ FINDSTR /I /V 'Name' ') do (echo wsh.echo '%%b' ^& ' free=' ^& FormatNumber^(cdbl^(%%a^)/1024/1024/1024, 2^)^& ' GB'^& ' size=' ^& FormatNumber^(cdbl^(%%c^)/1024/1024/1024, 2^)^& ' GB percent=' ^& Round^(100.cdbl^(%%a^) / cdbl^(%%c^), 0^) '%temp%tmp.vbs' if%%G LEQ 10(echo( cscript //nologo '%temp%tmp.vbs' del '%temp%tmp.vbs'))) D:moitorscriptslogDiskspace.txt–Aug 5 '15 at 11:13.