【问题标题】:Open or close cd-drive using cmd使用 cmd 打开或关闭 cd-drive
【发布时间】:2018-03-28 00:25:37
【问题描述】:

是否有任何方法可以使用 cmd 关闭和打开 cd-drive?

我可以这样打开:

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

但是我知道如何关闭它

(当然可以推进去,但我是说怎么用cmd关闭)

【问题讨论】:

标签: powershell cmd windows-7 windows-10


【解决方案1】:

【讨论】:

    【解决方案2】:
    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 您可能必须禁用防病毒软件

    【讨论】:

    • 该问题专门询问在 cmd 中执行此操作,即 cmd.exe 或 Windows 命令提示符。您提交的是 Visual Basic 脚本。为了使它能够从 cmd 运行,您需要 edit 您的答案,以便它包含足够的信息,以便未来的读者能够知道如何从该特定界面运行它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-10
    • 1970-01-01
    • 1970-01-01
    • 2012-04-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多