這個 vbs 較簡單 (在自己電腦, 1=第一個CDROM, 2=第2個):
On Error Resume Next
Set oWMP = CreateObject("WMPlayer.OCX.7" )
Set colCDROMs = oWMP.cdromCollection
colCDROMs.Item(1).Eject
A1= Msgbox ("Press The OK Key To Close The CD" , 0 + 32,"Close CD")
colCDROMs.Item(1).Eject
或較複雜, but 沒有要自行關 wscript.exe:
複製程式
On Error Resume Next
Const Hidden = 0, Normal = 1, Min = 2
Dim Act : Set Act = CreateObject("Wscript.Shell")
Set oWMP = CreateObject("WMPlayer.OCX.7" )
Set colCDROMs = oWMP.cdromCollection
colCDROMs.Item(1).Eject
A1= Msgbox ("Press The OK Key To Close The CD" , 0 + 32,"Close CD")
colCDROMs.Item(1).Eject
Act.Run("%comspec% /c TASKKILL /F /T /IM Cscript.exe"),Hidden,True
Act.Run("%comspec% /c TASKKILL /F /T /IM Wscript.exe"),Hidden,True
Act.Run("%comspec% /c TASKKILL /F /T /IM Wmiprvse.exe"),Hidden,true