Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1144
  • Last Modified:

Retrieving Actual Disk Size with VBScript

I currently have a script written that retrieves the amount of space being used on a drive.  It shows the "Size" but not the "Size on Disk".  When you right click on a folder or drive and say properties it shows the "Size on Disk" which is the accuracy that I need for my script.  But I can't find how to retrieve this info using vbscript.  Does anybody know any links to sample code that does this.  Any suggestions appreciated.
0
Sacrificial_Lamb
Asked:
Sacrificial_Lamb
1 Solution
 
DexstarCommented:
Sacrificial_Lamb:

> It shows the "Size" but not the "Size on Disk".  When you right click on a
> folder or drive and say properties it shows the "Size on Disk" which is the
> accuracy that I need for my script.

The FileSystemObject doesn't support that property.  You could write your own COM object that uses the Win32 APIs to look it up, and then invoke that from VBScript.

You could also compute the value using the sector size of the disk, like this:
     SizeOnDisk = CInt((objFile.Size / SECTOR_SIZE) + 0.5)*SECTOR_SIZE

But that isn't going to be 100% accurate, and it won't help you if the file is compressed via NTFS compression.

Hope that helps,
Dex*
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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