Pierre Bru said:
hello,
how can I check that D: exists and when exists that it is a HD, not a
ZIP, CDROM or whatever ?
TIA,
Pierre.
A few ways. If you're generally just looking for a CD-Rom drive, you want to
enumerate the local drives and find one which is of type CD-ROM; the
following code runs through all of the drives and returns their letter and
type:
===========================
UnknownType = 0
Removable = 1
Fixed = 2
Remote = 3
CDRom = 4
RamDisk = 5
dim fso: set fso = createobject("Scripting.FileSystemObject")
for each drive in fso.drives
wscript.echo drive.DriveLetter, drive.DriveType
next
===========================
If you want to get a listing of CD drives, the following function and
example code will do it for you -
option explicit
dim cd, cds
cds = CDRomDrives()
for each cd in cds
wscript.echo cd
next
function CDRomDrives()
' returns array containing letters of all local CDRom drives
dim CDRom, fso, tmp(), drive
CDRom = 4
set fso = createobject("Scripting.FileSystemObject")
redim tmp(-1)
for each drive in fso.drives
if drive.DriveType = CDRom then
redim preserve tmp(ubound(tmp) + 1)
tmp(ubound(tmp)) = drive.DriveLetter
end if
next
CDRomDrives = tmp
end function