Batch file to determine drive size

Hewlett-packard / Nc8430
January 19, 2009 at 09:46:15
Specs: Windows XP, Intel 2GB
I have a batch file that I am using to format a USB Key and then make it bootable to Window PE. We are using XP and it does not expose NTFS as an option for formatting, so we are formatting FAT32 and then converting the file system to NTFS. This is all working fine, but I am trying to add a check to the batch. We have found that WINPE doesn't like to boot from a USB key larger then 2GB on most systems, so we want to make sure that the key that is being used is no larger then 2GB. Here is where I am needing help. How can I check the partition size on a given drive letter to verify it is less then 2GB in size before performing the format and convert?

See More: Batch file to determine drive size

Report •

January 20, 2009 at 00:57:15
Doing it before a format is a little difficult if there are files on the drive, but the below should work on empty drives.
>drive:\test type nul
for /f "tokens=3 delims=	 " %%a in ('dir drive:\ /-c') do set dsize=%%a
if %dsize% gtr 1997766657 echo to large!

Report •

January 20, 2009 at 04:44:28
"using XP and it does not expose NTFS as an option for formatting"

Not obvious why. w2k does.

If you're running DOS you can:

fdisk /status

More to the point, you can MAKE a =< 2GB.

If at first you don't succeed, you're about average.


Report •

January 20, 2009 at 12:08:09
In xp you have to go to into the device manager right click on the flash drive under disk drives, choose policies and select optimise for performance.

I believe the option is designed to stop people that decide they don't need to unmount flash drives from loosing their data.

I'm sure there is probably a regedit that could disable this..........

Report •

Related Solutions

Ask Question