使用 cmd 打开或关闭光驱

Open or close cd-drive using cmd

是否有任何方法可以使用 cmd 关闭和打开光驱?

我可以这样打开:

powershell (New-Object -com "WMPlayer.OCX.7").cdromcollection.item(0).eject()

但是我不知道如何关闭它

(Of course I can push it in, but i mean how i can close it with cmd)

在 Google 上发现关键字:

powershell close cd rom drive

http://www.powershellmagazine.com/2013/11/12/pstip-ejecting-and-closing-cdrom-drive-the-powershell-way/

do
Dim ts
Dim strDriveLetter
Dim intDriveLetter
Dim fs 'As Scripting.FileSystemObject
Const CDROM = 4
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
strDriveLetter = ""
For intDriveLetter = Asc("A") To Asc("Z")
Err.Clear
If fs.GetDrive(Chr(intDriveLetter)).DriveType = CDROM Then
If Err.Number = 0 Then
strDriveLetter = Chr(intDriveLetter)
Exit For
End If
End If
Next
Set oWMP = CreateObject("WMPlayer.OCX.7" )
Set colCDROMs = oWMP.cdromCollection
For d = 0 to colCDROMs.Count - 1
colCDROMs.Item(d).Eject
Next 'null

For d = 0 to colCDROMs.Count - 1
colCDROMs.Item(d).Eject
Next 'null

set owmp = nothing
set colCDROMs = nothing
loop

另存为.vbs 您可能必须禁用防病毒软件