• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 943
  • Last Modified:

[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?
0
Klantenteam4
Asked:
Klantenteam4
1 Solution
 
willettmeisterCommented:
what about freedisk in the resource kit.

http://activexperts.org/admin/scripts/reskit/reskit2000/0083/
0
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now