user3305379
user3305379

Reputation: 35

How to remove virtual CD/DVD-ROM

On win10 we have possibility to mount iso files. For each mounted iso system creates virtual CD/DVD-rom drive. To see these drives we can use powershell:

PS C:\> gwmi win32_cdromdrive

Caption Drive Manufacturer VolumeName
------- ----- ------------ ----------
Microsoft Virtual DVD-ROM Volume{b62e0d58-541d-11e6-a1f7-005056873534} (Standard CD-ROM drives)
Microsoft Virtual DVD-ROM Volume{d2c8b686-5410-11e6-a1f6-005056873534} (Standard CD-ROM drives)
Microsoft Virtual DVD-ROM CdRom13 (Standard CD-ROM drives)
Microsoft Virtual DVD-ROM CdRom14 (Standard CD-ROM drives)
Microsoft Virtual DVD-ROM CdRom15 (Standard CD-ROM drives)
Microsoft Virtual DVD-ROM CdRom16 (Standard CD-ROM drives)
Microsoft Virtual DVD-ROM CdRom19 (Standard CD-ROM drives)
Microsoft Virtual DVD-ROM Volume{b62e1bc8-541d-11e6-a1f7-005056873534} (Standard CD-ROM drives)
NECVMWar VMware IDE CDR10 ATA Device D: (Standard CD-ROM drives)

Now my question is how to delete these devices using winapi/powershell whatever ?

I know that they are deleted when u dismount particular image using Dismount-DiskImage, but I would like to have "force" option.

Upvotes: 0

Views: 4897

Answers (1)

DisplayName
DisplayName

Reputation: 1026

$sh = New-Object -ComObject "Shell.Application"
$sh.Namespace(17).Items() | 
    Where-Object { $_.Type -eq "CD Drive" } | 
        foreach { $_.InvokeVerb("Eject") }

Where-Object { $_.Type -eq "CD Drive" } can you right click on iso drive what file system you see?

Upvotes: 2

Related Questions