Vbscript find free space on CD/DVD

I know that you can find the free space available for a hard disk using a vbscript, but is there a way to find the free space for a CD or DVD? I'm using the following code and keep getting 0.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set drive = objFSO.GetDrive(objFSO.GetDriveName("d:\"))

wscript.echo FormatNumber(drive.FreeSpace/1048576, 1)&"Mb"
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

That code will work for checking free space given whatever Drive your cd is in.  The problem is that once a CD session is closed it reports as 0 free space..  even if the cd itself is not at capacity.  I get the sense you are trying to write something to move data to a cd and programmatic tell you if you need to use more than one disk?
abgtempAuthor Commented:
Nah. Actually, I have a script that is pulling an ISO image from a directory, retrieving it's size and then burns the image to a CD. After the burn is complete, I want to do a validation that the image was burned successful by comparing original image size with the used space on the CD.
old script I found.  It tells you the disk size of each drive.  just set it to your cd rom drive.  Once you close a session on a drive whatever the size of the burnt image is the total size of the partition on the disk.  It works on my machine.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk")
For each objDisk in colDisks
	disksize = objDisk.size/1048576
    Wscript.Echo "Size: " & vbTab &  disksize    

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
abgtempAuthor Commented:
Thanks. That worked for me. And I don't know why I was trying to get the free space originally since what I needed what the used space. I bumping the points up for the quick response and giving me an idea for later on if I do have to figure out how many disks to use.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.