Jump to content

How to get freedisk space?


Recommended Posts

Hey everrybody!!!

in command line (MS DOS), how to get freedisk space of the drive that installed application?

My application's space is 1GB, I want to check freedisk space of the drive to know that has enough space for my application after my application installed.

pls help me!!!

Thanks!!!

Edited by sonoop
Link to comment
Share on other sites


I'd suggest that you would enter the amount of space you require to have free as a parameter and the utility would return 0 for yes and 1 for no.

If your question is not a mistake you will need to bear in mind that some methods of checking on MS-DOS 5 will suffer at 1Gb and completely fail at over 2Gb. 1Gb does seem like a very large requirement for that Operating System. I think that the standard method of manually checking free disk space was to issue chkdsk [drive]:

Link to comment
Share on other sites

@Wise Owl: thank you!

I get value "59451776 KB available on disk." by chkdsk command, how to get this value compare with value of my application?

My application is need 50GB free disk space.

Link to comment
Share on other sites

Since you are working in kilobytes you would need to multiply your gigabytes figure by 1048576 and use that for your check.

i.e. 50 GB x 1048576 = 52428800 kB

(As you can see, in this case your 59451776 kB is sufficient to accomodate your requirements)

Please note that you should never fill a hard disk to capacity, (you may be advised to allow for extra as a safety factor)

Link to comment
Share on other sites

@Mod: thanks, I know, But I cant write a command to compare. can you show me code?

@allen2: that's my exp. my mean is "get free disk space of a drive to compare with my app's space need". Can you show me code use chkdsk, dir, fsutil?

Link to comment
Share on other sites

As said before, chkdsk was the common way back then.

My application is need 50GB free disk space.

Then checking for space is useless: it'll always return false. MS-DOS 5 only supports FAT12 (for floppies) and FAT16 (for hard drives) which is limited to 2GB* so you'll NEVER have 50GB free. You will never have more than 2GB free (that would be a 100% empty drive of the biggest size you can use). Checking for disk space is completely trivial (I would simply call int 21 with ah=36h and dl=3), but bypassing such a design limitation of FAT16 is just not possible. Even trying to parse the output of chkdsk which simply returns bytes/sector (512) * sectors/cluster (64 max) * amount of free clusters (max 65536) is pointless: the max it could ever display is 2147483648 bytes, and that's still 48GB short of what you need. Your current drive

* 2^16 clusters @ 32KB/ea max (64KB clusters not supported) = 2GB max.

Edit: unless you're mixing up MB and GB, or aren't using MS-DOS 5, or somehow using another non-native filesystem that's tacked on by hooking interrupts or such, then it's a completely different story.

Edit2: why did you say you're using MS-DOS 5 when you're using XP? :blink:

Link to comment
Share on other sites

sorry all, i cant speak english verry well.

I building a GUI Installation for my application, and I write a script with wizapp like a batch file in command line.

My application need space free of the drive, and I want to check free disk space after my application installed.

How to check......... (in command line)?

chkdsk, dir, fsutil --> show string value free

freedisk.exe --> return 0 if there is enough space and return 1 if there isnt.

download freedisk.exe http://www.mediafire.com/?eio9qcg5mtr58kl copy to drive D

code:

freedisk.exe D: 59825229820 (small than freedisk space)

a.jpg

result: to small!!! (return 1) --> it's wrong.....

And I'm so sorry all about version dos confusion.

Thank you!!!

Edited by sonoop
Link to comment
Share on other sites

Its no good providing a command line for XP (with service pack 2) if users of previous operating systems could potentially install the application. The parsing of output from commands such as DIR can change according to the OS, FSUTIL is not available on all OS's.

What is your application, it will very likely already have been coded to check for disk space as part of it's routine?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...