我需要打开然后几秒钟后,用VBS关闭CD驱动器。 我现在所知道的只是用这段代码弹出驱动器
Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
if colCDROMs.Count >= 1 then
colCDROMs.Item(i).Eject
End If
这个简单的问题可能看起来很愚蠢,但请原谅我,我不是程序员。
答案 0 :(得分:1)
试试这个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
'****************************************
答案 1 :(得分:0)
尝试这个
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
这对我有用。