This is a script I wrote back in 2006 which lists all the CD/DVD drives on a computer (or multiple computers) and then displays the volume name of any disks found in the drive. The script is written in VBScript.
Last tested on Windows XP, Vista and 7 and Windows Server 2003 and 2008
Usage is CDinf.vbs server1 [server2] [server3] …

' This script lists all CD drives on a computer
' and volume names of any CDs in the drives.
On Error Resume Next
ComputersChecked = 0
Wscript.Echo "Ellis Karim, 2006 "
WScript.Echo "CDinf.vbs version 1.0a"
WScript.Stdout.WriteBlankLines 1
If WScript.Arguments.Count = 0 Then
WScript.Echo "Usage: CDinf.vbs server1 [server2] [server3] ..."
WScript.Quit
End If
For Each Computer In WScript.Arguments
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & Computer & "\root\cimv2")
If Err.Number <> 0 Then
'Computer not found
WScript.Echo UCase(Computer) & "> " & Err.Description
Err.Clear
Else
ComputersChecked = ComputersChecked + 1
Set colDisks = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk ")
For Each objDisk in colDisks
If objDisk.DriveType = 5 Then
WScript.StdOut.Write UCase(Computer) & "> Drive " & objDisk.DeviceID & " CD-ROM Drive ("
If IsNull(objDisk.VolumeName) Then
WScript.Echo "--empty--)"
Else
WScript.Echo objDisk.VolumeName & ")"
End If
End If
Next
End If
Next
wscript.Stdout.WriteBlankLines 2
Wscript.Echo "Script completed " & Now & ". "
Wscript.Echo ComputersChecked & "/" & WScript.Arguments.Count & " computers were checked."
Leave a Reply