Hey, Scripting Guy! How can I tell if a computer has a DVD drive installed?
Hey, GC. No doubt you’re hoping we’ll say something like, “Why, you just use the Win32_DVD class, of course.” Unfortunately, though, we can’t say that; that’s because there is no Win32_DVD class, or any class devoted to DVD drives. There is, of course, the Win32_CDROMDrive class, but it doesn’t have any properties like, say, DVDDrive. Looks bleak, doesn’t it?
But don’t worry, it - well, OK, in some cases it is bleak. But in other cases there is a workaround. If you have a DVD drive, the acronym DVD will often appear in the Caption property of the Win32_CDROMDrive class. For example, the Caption property might have a value similar to this:
QSI CDRW/DVD SBW242U
See the letters DVD? That indicates that this is a DVD drive. Like we said, not 100% foolproof, but most DVD drives will include the letters DVD in the Caption property.
You might also note the letters CDRW in the caption. As you might guess, those letters stand for CD Read/Write; turns out this particular drive not only can play DVDs, it can also read and write CDs. This is another question we get asked quite a bit: how can you tell whether or not a CD drive can write CDs? Checking for the letters RW within the Caption property is probably your best bet for that as well. Supposedly this can also be done by checking for the value 4 in the Capabilities property, but, to be honest, we have yet to see the value 4 returned from a drive capable of writing CDs. You’re better off using the Caption property.
Oh, yeah; we almost forgot. Here’s a sample script that returns the drive letter and caption for all the CD/DVD drives installed on a computer:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")
For Each objItem in colItems
Wscript.Echo "Drive Letter: " & objItem.Drive
Wscript.Echo "Caption: " & objItem.Caption