Monday, 23 May 2011

cd tray open and close by click this code

>open notepad

>copy and paste the below code:
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
MSGBOX "YOUR CD IS: " & strDriveLetter,VBOKONLY + 48,"CDROM=> " & strDriveLetter
Set oWMP = CreateObject("WMPlayer.OCX.7" )
Set colCDROMs = oWMP.cdromCollection
     For d = 0 to colCDROMs.Count - 1
           colCDROMs.Item(d).Eject
Next 'null
'A1= msgbox ("Press key To Close Cd" & vbcrlf &_
' " The Cd Will Close", 0 + 64, "Open Close Cd Tray")
'     For d = 0 to colCDROMs.Count  1
'            colCDROMs.Item(0).Eject
'Next 'null

set owmp = nothing
set colCDROMs = nothing
wscript.quit
>save it as cd.vbs
>now click that cd.vbs file

No comments:

Post a Comment