The vbs For Eject And Then Close A CD-ROM Or DVD Drive | Prain的 ...

This article reproduced from the Don Hite’s BLOG

This By Request VBS Script is in response to an email request where I was asked the following: “I have a VB script to open my CD drive but I have to close it myself. Can you tell me what the command to close it is. All I can find is the eject command.”

Set objCdDrive = CreateObject("WMPlayer.OCX.7")

Set colCDROM = objCdDrive.cdromCollection

If colCDROM.Count >= 1 then

For i = 0 to colCDROM.Count – 1

colCDROM.Item(i).Eject

Next

End If

My reply was just loop it using and additional Next and I sent him back the script below.

Note: If the Drive door is already opened when you run this VBS script it will just close the door. On laptops the mechanics may not be the same as desktops and the drive door will only open since it cannot be pulled back in.

VBS Script:

Set objCdDrive = CreateObject("WMPlayer.OCX.7")

Set colCDROM = objCdDrive.cdromCollection

If colCDROM.Count >= 1 then

For i = 0 to colCDROM.Count – 1

colCDROM.Item(i).Eject

Next

For i = 0 to colCDROM.Count – 1

colCDROM.Item(i).Eject

Next

End If

相关文章:

中文关键字:

留下脚印

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

by WP-SpamFree

郑重声明:资讯 【The vbs For Eject And Then Close A CD-ROM Or DVD Drive | Prain的 ...】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——