Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for presence of disk in CD/DVD drive

Status
Not open for further replies.

phudgens

Technical User
Jul 8, 2004
117
US
I am using the following code to determine the label given to a data CD/DVD when first created:

Dim d, dc
CDLabel = ""
Set fs = CreateObject("Scripting.FileSystemObject")
Set dc = fs.Drives
For Each d In dc
If d.DriveType = 4 Then
CDLabel = d.volumename
End If
Next

However, if there is no disk in the drive, an error message is posted. How do I check for the presence of a CD prior to running this code? Also, is the CD drive always going to be DriveType=4?

Thanks,
Paul Hudgens
 
That works! Thanks very much,

Paul H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top