This repository was archived by the owner on Jan 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1207,14 +1207,12 @@ function ejectContextCD($cdrom_drive)
12071207 if ($eject_cdrom -ne $null -and $eject_cdrom.ToUpper () -eq ' YES' ) {
12081208 logmsg ' * Ejecting context CD'
12091209 try {
1210- $disk_master = New-Object - ComObject IMAPI2.MsftDiscMaster2
1211- for ($cdrom_id = 0 ; $cdrom_id -lt $disk_master.Count ; $cdrom_id ++ ) {
1212- $disk_recorder = New-Object - ComObject IMAPI2.MsftDiscRecorder2
1213- $disk_recorder.InitializeDiscRecorder ($disk_master.Item ($cdrom_id ))
1214- if ($disk_recorder.VolumeName -eq $cdrom_drive.DeviceID ) {
1215- $disk_recorder.EjectMedia ()
1216- break
1217- }
1210+ # https://learn.microsoft.com/en-us/windows/win32/api/shldisp/ne-shldisp-shellspecialfolderconstants
1211+ $ssfDRIVES = 0x11
1212+ $sh = New-Object - ComObject " Shell.Application"
1213+ $sh.Namespace ($ssfDRIVES ).Items() | Where-Object { $_.Type -eq " CD Drive" -and $_.Path -eq $cdrom_drive.Name } | ForEach-Object {
1214+ $_.InvokeVerb (" Eject" )
1215+ logmsg " ... Ejected $ ( $cdrom_drive.Name ) "
12181216 }
12191217 } catch {
12201218 logmsg " ... Failed to eject the CD: $_ "
You can’t perform that action at this time.
0 commit comments