我正在寻找一种方法来获取DVD或CD-ROM的列表在PC上以及它们的标签名称(如果插入任何DVD或CD),使用VB脚本。
目前有一些脚本会返回所有设备'信件但我只需要DVD和CD ROM。
答案 0 :(得分:1)
DriveType
类的Drive
属性报告驱动器的类型。以下是此枚举的值:
Const DriveTypeUnknown = 0
Const DriveTypeRemovable = 1
Const DriveTypeFixed = 2
Const DriveTypeNetwork = 3
Const DriveTypeOptical = 4
Const DriveTypeRAMDisk = 5
只需迭代Drives
类的FileSystemObject
集合。请注意,CD和DVD驱动器之间没有区别(也没有读/写)。
Set objFSO = CreateObject("Scripting.FileSystemObject")
For Each objDrive In objFSO.Drives
If objDrive.DriveType = DriveTypeOptical Then
' Attempt to get the volume name. It will only be available if a disc is loaded.
If objDrive.IsReady Then
strLabel = objDrive.VolumeName
Else
strLabel = "(no disc)"
End If
WScript.Echo "Optical Drive = " & objDrive.DriveLetter & ", Label = " & strLabel
End If
Next