Wasn't quite sure where to put this so if the Mods want to move it feel free.
Just browsing VB sites and found a function that ejects the cdrom of your choice using the WMP SDK.
I just thought I'd incorporate it into a simple script file so that it can be sued/linked from the dock.
Anyway here it is:
Option Explicit
On Error Resume Next
Dim WshShell, chkOpen, RegEntry, RegCheck, ErrNum, wmp, cdroms
Set WshShell = WScript.CreateObject("WScript.Shell")
Set wmp = CreateObject("WMPlayer.OCX.7")
Set cdroms = wmp.cdromCollection
const Drive = "0"
RegEntry = "HKCU\Software\CDTray\"
RegCheck = WSHShell.RegRead (RegEntry)
ErrNum = Err.Number
if ErrNum <> 0 then
WshShell.RegWrite "HKCU\Software\CDTray\", 0 ,"REG_DWORD"
WshShell.RegWrite "HKCU\Software\CDTray\OpenClose", "1"
End If
chkOpen = WshShell.RegRead ("HKCU\Software\CDTray\OpenClose")
If chkOpen = "1" Then
If cdroms.Count >= 1 then
cdroms.Item(Drive).Eject
End If
WshShell.RegWrite "HKCU\Software\CDTray\OpenClose", "0"
Else
If cdroms.Count >= 1 then
cdroms.Item(Drive).Eject
cdroms.Item(Drive).Eject
WshShell.RegWrite "HKCU\Software\CDTray\OpenClose", "1"
End If
End If
WshShell.Run "Taskkill.exe /F /IM WScript.exe", 0, TRUE
Set WshShell = vbnull
Set wmp = vbnull
Set cdroms = vbnull
Just copy and paste into a vbs file and then drag it to your dock. ![]()
By the way, you can select which drive you want it to link to by changing the constant 'Drive', where o is your first Drive and 1 would be your second drive etc.
Hope someone finds a use for it! ![]()
Aqua-Soft Forums
I dunno what the exact problem is but you get loads of 'wscript.exe' instances in your task list!