1.

Solve : Eject CD with Batch file?

Answer»

I have created a special Pinball game for my Racquetball friends. I am using a batch file to construct a CD that will install the Pinball game. After the last Install command, I would like the (handout) Installation CD to auto eject for each of my friends (the end USERS).

Nutshell QUESTION: Can we build a batch command that can be copied onto a CD(Music or Text) that will cause the CD to auto eject after "the last song is sung".

Echo off
Start "" /max HelloInstall.wmv
pause
Call "1st Setup.msi"
Call "2nd Setup.exe"
pause
Call "3rd Setup.bat"
pause
Start "" EjectCD.exe
exit


The EjectCD application does not eject the CD, it simply makes it possible to eject the CD by clicking on a taskbar icon.

Instead of Start "" EjectCd.exe, Could I have a 4th Setup.bat that simply sends a message to eject the CD?

Is it possible to send a dos command to double click a taskbar icon?

Is it possible to create a hot key that will eject a cd?
Is it possible to send a message to a hot key .... to tell it to press itself?

Is it possible to tell a close button (X) to click itself?

Is it possible for a dos command to emulate the mouse clicking on anything? Example:
MouseClicks on CdRom\file\eject = CD tray opens
Start "" D\Toolbar\file\eject\MouseClick
This little snippet will turn your cd drive into a cup holder.

Code: [Select]
Dim WMP: Set WMP = CreateObject("WMPlayer.ocx")
Dim colCDROMS: Set colCDROMS = WMP.CDROMCollection

If colCDROMS.Count > -1 Then
For i = 0 to colCDROMS.Count - 1
colCDROMS.Item(i).Eject
Next
End If


Save the script with a vbs extension. You cannot mix batch language with scripts, but there is nothing preventing a batch file from calling a script:

call cscript scriptname.vbs

As far as your questions go, the short answer is no. DOS provides no Window objects and deals strictly at the command level. Windows on the other hand, provides COM objects which can be scripted or programmed.

Hope this helps.

Disclaimer: the above script does not work correctly on XP SP2 machines. Hey Sidewinder,

LOL

That cupholder JOKE was the funniest computer joke I have ever heard. It will be in my next book.

Seriously, Reference: Amazon.com (books)

"200 Love Hints; 300 jokes"
By Wayne and Carolyn Thornton

Thanks again
WayneThornton Hey Sidewinder. Thanx for the vbs to open the cd tray. You mentioned that you thought it wouldn't work on XP SP2, but it did for me. What vbs would MAKE the tray close? MikeyIt doesn´t work on my NT4 machine. :-(

ulidont hold me to this but i dont think there is a command that will close the cd rom.

ok onto my question is it possible to open eery cd rom on a network.

thanksWhy not install the game to hardrive.......winme has pinball installed on it......Hey uli_glueck, you may need this file- vbrun60sp5.exe - it's a free download . I didn't do anything special to get the vbs mentioned by Sidewinder to work.

Bil, actually, there is code or something (there are programs that close the cd tray), to close the cd tray, I've tried various vbs's listed by different people, but haven't found one that works yet. Yes, I could use one of the programs, but I am interested in learning the code, vbs or whatever. BTW, I haven't seen anything to open all cd trays on a network.i get a (5, 6) microsoft vbscript compilation error: expected identifier errorQuote

This little snippet will turn your cd drive into a cup holder.

Code: [Select]
Dim WMP: Set WMP = CreateObject("WMPlayer.ocx")
Dim colCDROMS: Set colCDROMS = WMP.CDROMCollection

If colCDROMS.Count > -1 Then
For i = 0 to colCDROMS.Count - 1
colCDROMS.Item(i).Eject
Next
End If


lol it worked with me, even under windows xp sp2!, it's the funniest script i ever have seen!
Good grief. Are we so bored we start dragging them back from the crypt? Anyways, here's an update:

Quote
the above script does not work correctly on XP SP2 machines


The script works as advertised, however the intepreter program (wscript or cscript) continues to execute. If you run the script and then bring up the task manager you can see for yourself. Not critical but very sloppy. Probably a bug in the WMP object.

The script will work on network drives provided they are mapped to the local machine.

Not all machines have WMPlayer.ocx; TRY using WMPlayer.ocx.7

Now, can we give this a burial we can all be proud of? Oh, eject...not open Tongue

You can use this little script:

Set WMP = CreateObject("WMPlayer.OCX.7" )
Set CDROMs = WMP.cdromCollection

If CDROMs.Count >= 1 Then
For i = 0 to CDROMs.Count - 1
CDROMs.Item(i).Eject
Next
End If

Save the script with a VBS extension, then run it. It only works for CDROMS.

Hope this helps Cool

this is from one of your posts Sidewinder
this one works with all comps


Discussion

No Comment Found