Monday, 23 September 2013

> How to Open a Cd tray in Laptop using 3 lines of Visual Basic Scripts

 > Open Notepad.
 > Copy the Following VS code.
 > Save the File as (Any name).vbs format [ Eg:              open_cd_tray.vbs ]

1. Set creatingwscript = WScript.CreateObject("wscript.Shell")

2. Set play = CreateObject("WMPlayer.ocx")

3. play.cdromCollection.item(0).Eject()

 > How it Works ?
 > First create an Object using wscript as "wscript.Shell" as    parameter.
 > Set it with any Object name here i used creatingwscript.
 > And again create another one Object "WMPlayer.ocx".
 > Set another one Object name here i have used play.
 > Call the method [cdrom.Collection.item(0).Eject() using  play Object.
 > item(Here 0 is used because only one tray is present in  laptops).  




No comments:

Post a Comment