我需要打开光驱,几秒钟后,用VBS关闭光驱。我现在知道的就是用这个代码弹出硬盘
Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
if colCDROMs.Count >= 1 then
colCDROMs.Item(i).Eject
End If这么简单的问题可能看起来很愚蠢,但请原谅我不是程序员。
发布于 2017-06-30 08:29:07
尝试此vbscript:
Option Explicit
'To open the CD-Rom
Call Open_Close_CD()
'Make a pause for 20 seconds and you can modify it for your needs
Call Pause(20)
'To Close the CD-Rom
Call Open_Close_CD()
'****************************************
Sub Open_Close_CD()
Dim oWMP,colCDROMs,i
Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
if colCDROMs.Count >= 1 then
colCDROMs.Item(i).Eject
End If
End Sub
'****************************************
Sub Pause(NSeconds)
Wscript.Sleep(NSeconds*1000)
End Sub
'****************************************发布于 2018-12-14 12:46:35
尝尝这个
Set TI = CreateObject("WMPlayer.OCX.7" )
Set CDROM = TI.cdromCollection
if CDROM.Count >= 1 then
For i = 0 to CDROM.Count - 1
CDROM.Item(i).Eject
Next ' CDTRAY
For i = 0 to CDROM.Count - 1
CDROM.Item(i).Eject
Next ' CDTRAY
End If这对我很有效。
https://stackoverflow.com/questions/44836437
复制相似问题