Solved

Retrieving Actual Disk Size with VBScript

Posted on 2003-11-12
1
1,101 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
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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 …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

747 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now