[cmd script] Report the hard disk size, else give error

Hello,

I am using Altiris to install Windows Server SP2 on several servers. But this cannot be done when the hard disk space is too low.
I want to make a pre-job that reports the hard disk free space so when this value is too low there will be an error code (and the job stops).

So far I have this line of code:
 dir c:\|find /i "bytes free" >> drivespacefree.txt

But now the reported value has too be checked if it is under 2.000.000.000 bytes.

Any thoughts?
Klantenteam4Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

willettmeisterCommented:
what about freedisk in the resource kit.

http://activexperts.org/admin/scripts/reskit/reskit2000/0083/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dougaugCommented:
Try this (copy it in a file with .vbs extension, for example, checkspace.vbs)

VolLetter="C"

Set fso = CreateObject("Scripting.FileSystemObject")
Set vol = fso.GetDrive(VolLetter)

' Check if the drive is fixed
If vol.DriveType = 2 Then
  If vol.freespace < 2000000000 Then
     msgbox "There is not enough space on drive " & vol.DriveLetter & ": " & vol.freespace & " bytes free"
  End if
Else
  msgbox "Drive is not a HDD"
End if
0
Justin_W_ChandlerCommented:
Here you go!
@echo off

:: SET YOUR MINIMUM NUMBER OF MEGABYTES FREE BELOW
set const_minFree=2000

for /f "tokens=4" %%A in ('dir /-c c:^|find "bytes free"') do set var_freeSpace=%%A
set /a var_freeSpace=%var_freeSpace:~0,-6%
if %var_freeSpace% LSS %const_minFree% echo NOT ENOUGH FREE SPACE

Open in new window

0
Klantenteam4Author Commented:
.
0
Justin_W_ChandlerCommented:
Did you test my script? Please do so and verify it functions as required.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.