5

How to detect current media type in CLI under Windows? (DVD-RW, BD-R, etc)

I've tried with wmic cdrom get /format:list but no info about the current media type.

I want to detect if the disc is a CD, DVD, BD, RW, DL... etc. In Windows GUI under Computer we can see the information according to the icon displayed for the optical drive.

Also, I can't find the meaning of the Availability and the Capabilities values, if you know a document talking about it, it would be great.

C:\>wmic cdrom get /format:lis

Availability=3
Capabilities={3,4,7}
CapabilityDescriptions={"Random Access"," Supports writing"," Supports Removable
 Media"}
Caption=HL-DT-ST BD-RE  BH12LS35
CompressionMethod=Unknown
ConfigManagerErrorCode=0
ConfigManagerUserConfig=FALSE
CreationClassName=Win32_CDROMDrive
DefaultBlockSize=
Description=CD-ROM Drive
DeviceID=SCSI\CDROM&VEN_HL-DT-ST&PROD_BD-RE__BH12LS35\4&15828421&amp
;0&050000
Drive=G:
DriveIntegrity=TRUE
ErrorCleared=
ErrorDescription=
ErrorMethodology=
FileSystemFlags=
FileSystemFlagsEx=21757959
Id=G:
InstallDate=
LastErrorCode=
Manufacturer=(Standard CD-ROM drives)
MaxBlockSize=
MaximumComponentLength=254
MaxMediaSize=
MediaLoaded=TRUE
MediaType=DVD Writer
MfrAssignedRevisionLevel=1.00
MinBlockSize=
Name=HL-DT-ST BD-RE  BH12LS35
NeedsCleaning=
NumberOfMediaSupported=
PNPDeviceID=SCSI\CDROM&VEN_HL-DT-ST&PROD_BD-RE__BH12LS35\4&15828421&
amp;0&050000
PowerManagementCapabilities=
PowerManagementSupported=
RevisionLevel=
SCSIBus=5
SCSILogicalUnit=0
SCSIPort=0
SCSITargetId=0
SerialNumber=
Size=39621033984
Status=OK
StatusInfo=
SystemCreationClassName=Win32_ComputerSystem
SystemName=PC
TransferRate=4363,63636363636
VolumeName=XMEN_D1
VolumeSerialNumber=8AF2C6DC

EDIT

Running Get-WmiObject Win32_PhysicalMedia | Select * give me the following result for the optical drive (a DVD is in the drive):

PSComputerName       : PC-JAY
__GENUS              : 2
__CLASS              : Win32_PhysicalMedia
__SUPERCLASS         : CIM_PhysicalMedia
__DYNASTY            : CIM_ManagedSystemElement
__RELPATH            : Win32_PhysicalMedia.Tag="\\\\.\\CDROM0"
__PROPERTY_COUNT     : 23
__DERIVATION         : {CIM_PhysicalMedia, CIM_PhysicalComponent, CIM_PhysicalElement, CIM_ManagedSystemElement}
__SERVER             : PC-JAY
__NAMESPACE          : root\cimv2
__PATH               : \\PC-JAY\root\cimv2:Win32_PhysicalMedia.Tag="\\\\.\\CDROM0"
Capacity             :
Caption              :
CleanerMedia         :
CreationClassName    :
Description          :
HotSwappable         :
InstallDate          :
Manufacturer         :
MediaDescription     :
MediaType            :
Model                :
Name                 :
OtherIdentifyingInfo :
PartNumber           :
PoweredOn            :
Removable            :
Replaceable          :
SerialNumber         :
SKU                  :
Status               :
Tag                  : \\.\CDROM0
Version              :
WriteProtectOn       :
Scope                : System.Management.ManagementScope
Path                 : \\PC-JAY\root\cimv2:Win32_PhysicalMedia.Tag="\\\\.\\CDROM0"
Options              : System.Management.ObjectGetOptions
ClassPath            : \\PC-JAY\root\cimv2:Win32_PhysicalMedia
Properties           : {Capacity, Caption, CleanerMedia, CreationClassName...}
SystemProperties     : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY...}
Qualifiers           : {dynamic, Locale, provider, UUID}
Site                 :
Container            :
Jeremy Dicaire
  • 165
  • 1
  • 5
  • 15

3 Answers3

5

I want to detect if the disc is a CD, DVD, BD, RW, DL... etc. In Windows GUI under Computer we can see the information according to the icon displayed for the optical drive.

You have the right command, the information you seek is under the "Caption" field.

So for:

wmic cdrom get /format:list

In your example, in the Caption field you can see it is a BD-RE (blu-ray Recordable

Caption=HL-DT-ST BD-RE BH12LS35

For your second question:

Also, I can't find the meaning of the Availability and the Capabilities values, if you know a document talking about it, it would be great.

The descriptions and everything related to this class are found on MSDN here:

Win32_CDROMDrive class (Windows)

TheCleaner
  • 32,352
  • 26
  • 126
  • 188
1

The Availability is what the media is capable of, and Capability is what your drive is capable of. So:

Availability=3
Capabilities={3,4,7}
CapabilityDescriptions={"Random Access"," Supports writing"," Supports Removable Media"}

This would mean that your current media supports reading only, but not writing. The "supports removable media" probably doesn't mean anything useful. Based on the Size=39621033984 parameter you have a standard DVD-R loaded. DL would be double that, and Blu-Ray more. Try experimenting with different media to see what the results are.

Nathan C
  • 14,901
  • 4
  • 42
  • 62
0

Have you tried the following code?

Get-WmiObject win32_cdromdrive -Filter "MediaLoaded=True" | Select Drive, MediaType 
MFT
  • 370
  • 2
  • 9