Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(fso.GetDriveName("D:"))
s = d.freespace
set fso = nothing
set myfile = nothing
msgbox(s)
If you have wmi installed, you could try that,
(works for me).
--- <snip> ---
Dim wmi : Set oWMI = GetObject("winmgmts:")
for each Disk in oWMI.InstancesOf("Win32_LogicalDisk")
Select Case Disk.DriveType
Case 2 ' diskette drive
Case 3 ' hard drive
Case 5 ' cd
MsgBox("drive type: CD" & vbCrLf _
& "Capacity: " & Disk.Size & vbCrLf _
& "UsedSpace: " & CStr(Disk.Size - Disk.FreeSpace) &
vbCrLf _
& "Freespace: " & Disk.FreeSpace)
Case Else MsgBox("unrecognized drive type")
End Select
next ' next cpu
WScript.Quit
--- </snip> ---
and, if you know sql, you could select the cdrom out of the drive
collection directly.
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
--- <snip> ---
Dim wmi : Set oWMI = GetObject("winmgmts:")
wmiQuery = "select * from Win32_LogicalDisk where DriveType=5"
Set colCDs = oWMI.Execquery(wmiQuery)
if (colCDs.Count <= 0) then WScript.Quit ' no cd drives
for each Disk in colCDs
MsgBox("drive type: CD" & vbCrLf _
& "Capacity: " & Disk.Size & vbCrLf _
& "UsedSpace: " & CStr(Disk.Size - Disk.FreeSpace) & vbCrLf _
& "Freespace: " & Disk.FreeSpace)
next ' next cpu
WScript.Quit
--- </snip> ---
cheers, jw
"mr_unreliable" <kindlyReply...@notmail.com> wrote in message
news:O04yD8e...@TK2MSFTNGP03.phx.gbl...
But the win32_CDROMDrive class does NOT have a freespace
property. And so the script shifts gears, and goes back
to the win32_LogicalDisk class to get the freespace.
Also, there is a bonus for you ultra-techie types. There
has been many postings concerning a minor point with wmi.
That is there seems to be no way to address a specific
item in a wmi collection with the "item" property, as in:
myCollection.Item(1).
In this script, you will find one example of that.