0

I'm using a simple script to check the status of CD/DVD drives on a machine. I want to be able to tell if a certain drive is writable. I have the following test code:

$script_obj = new-object -comobject wscript.shell
$drives = @(Get-WmiObject win32_logicaldisk -filter 'DriveType=5')
$script_obj.popup($drives[0].DeviceID + " " + $drives[0].Access)

This will show the drive letter of the CD/DVD drive on my machine, but the Access parameter always comes back as 0 (Unknown) even though I have a writable CD inserted into the drive. I have tried formatting the CD to be used the same as a USB device (as opposed to a music CD) so that I can open it to browse the file structure (there are no files), but this doesn't change anything.

Isn't the Access property supposed to give me 2 or 3 or 4 instead of 0?

EDIT:

I tried inserting a playable DVD and CD. DVD doesn't read, the CD works though. I was also able to burn a CD and play it on a normal CD player. Throughout this process I ran the command given by Jan below and got the same output every time:

PS C:\Users\ian> Get-WmiObject Win32_CDROMDrive | Select Caption, Drive, MediaType, Access

Caption                                                          Drive                                                            MediaType                                                        Access                                                          
-------                                                          -----                                                            ---------                                                        ------                                                          
hp CDDVDW SH-216AL                                               D:                                                               DVD Writer                                                                    

It doesn't matter whether or not anything is inserted into drive D, or what type of disk it is, this is the output. I'm suspicious that my drive is busted since it wouldn't read a video DVD, but I dunno. This was a refurbished desktop. Are there any more reliable ways to check for a writeable CD using PS?

Ian
  • 4,169
  • 3
  • 37
  • 62
  • Are you sure you don't have any virtual cdrom drives or anything of the like? You are only looking at the first object in you array. Check the results of `$drives` (just that in the console with nothing else) and perhaps you will find others? – Matt Jun 20 '15 at 00:46
  • @Matt: Yes, I'm sure I don't have virtual drives. The script prints out the drive letter, which I checked, and it is my physical CD/DVD drive. – Ian Jun 22 '15 at 14:12
  • Ah you suspect it is not working... Two things with that then. I wonder if the "Enable Recording on this drive" box is checked on the dvd drive properties (should not explain why it has blank access. Mostly just curious). Also does a consumer music cd work? It would help narrow down the possibility of failure. It's I trick I used to test older cd rom drives. – Matt Jun 22 '15 at 14:47
  • I don't see an "Enable Recording" checkbox in the "Recording" tab of the D drive properties. I can burn and read CD's. – Ian Jun 22 '15 at 16:59

2 Answers2

1

Access field in a CD/DVD drive will be blank, if there is no media in the drive. Once you insert a disk into the drive, you can read the MediaType, Access fields and lots of other info.

To find the Capabilities of a CD/DVD you can use Win32_CDROMDrive MediaType property.

PS > Get-WmiObject Win32_CDROMDrive | Select Caption, Drive, MediaType

Caption                                          Drive                                            MediaType                                       
-------                                          -----                                            ---------                                       
hp DVD A  DH16ABLH                               G:                                               DVD Writer

Reference - Checking if a CD/DVD drive is a Writer or just a Cd-Rom using WMI

Jan Chrbolka
  • 4,184
  • 2
  • 29
  • 38
  • As the questions states, I do have a blank CD in the drive. See edit for more info. – Ian Jun 22 '15 at 14:27
  • Win32_CDROMDrive is a much cleaner way to get the CD drive than I have posted. – Ian Jun 22 '15 at 14:36
0

I eventually found that my CD/DVD drive was on its way out. It wouldn't burn DVD's and eventually stopped reading or burning anything. I figure this has something to do with my troubles.

Ian
  • 4,169
  • 3
  • 37
  • 62