Solved

Retrieving Actual Disk Size with VBScript

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.

734 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