Solved

Retrieving Actual Disk Size with VBScript

Posted on 2003-11-12
1
1,130 Views
Last Modified: 2012-06-27
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
Comment
Question by:Sacrificial_Lamb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 19

Accepted Solution

by:
Dexstar earned 125 total points
ID: 9735722
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Introduction to Processes
Starting up a Project

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question