Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Eject CD with Batch file  (Read 20922 times)

0 Members and 1 Guest are viewing this topic.

WayneThornton

  • Guest
Eject CD with Batch file
« on: September 10, 2005, 12:04:50 PM »
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

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Eject CD with Batch file
« Reply #1 on: September 11, 2005, 04:04:55 AM »
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. 8)

Disclaimer: the above script does not work correctly on XP SP2 machines. :'(
« Last Edit: September 11, 2005, 04:13:17 AM by Sidewinder »
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

WayneThornton

  • Guest
Re: Eject CD with Batch file
« Reply #2 on: September 11, 2005, 11:00:41 AM »
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

Mikey

  • Guest
Re: Eject CD with Batch file
« Reply #3 on: September 25, 2005, 11:05:53 PM »
 8)   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?   Mikey

uli_glueck

  • Guest
Re: Eject CD with Batch file
« Reply #4 on: September 26, 2005, 01:57:00 AM »
It doesn´t work on my NT4 machine.  :-(

uli
« Last Edit: September 26, 2005, 01:58:36 AM by uli_glueck »

bil

  • Guest
Re: Eject CD with Batch file
« Reply #5 on: September 27, 2005, 01:30:38 PM »
dont 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.

thanks

merlin_2

  • Guest
Re: Eject CD with Batch file
« Reply #6 on: September 27, 2005, 06:27:42 PM »
Why not install the game to hardrive.......winme has pinball installed on it......

Mikey

  • Guest
Re: Eject CD with Batch file
« Reply #7 on: September 27, 2005, 07:06:06 PM »
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.
« Last Edit: September 27, 2005, 07:08:19 PM by Mikey »

everett gillert

  • Guest
Re: Eject CD with Batch file
« Reply #8 on: December 02, 2005, 07:31:41 PM »
i get a (5, 6) microsoft vbscript compilation error: expected identifier error

Blackberry



    Adviser
  • For those with wings, fly to your dreams.
    Re: Eject CD with Batch file
    « Reply #9 on: December 03, 2005, 02:11:42 AM »
    Quote
    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!
    Everybody knows you can't click here. But I know you will try it :)

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: Eject CD with Batch file
    « Reply #10 on: December 03, 2005, 06:28:03 AM »
    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? 8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    everett gillert

    • Guest
    Re: Eject CD with Batch file
    « Reply #11 on: December 03, 2005, 10:10:52 AM »
     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