Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Batch file for ejecting media


  • This topic is locked This topic is locked

#1
maxedison

maxedison

    New Member

  • Member
  • Pip
  • 1 posts
I currently have a batch file that will run the Safely Remove Hardware function (the same thing as double clicking on the safely remove hardware button in the system tray).

What I would really like, however, is for the batch file to actually go ahead and eject a specific media. Since my external hard drives always have the same drive letters, I feel like this should be possible.

Here's the text of the current batch file I'm using in case it helps. By the way, I know nothing about any of this programming.

REM SAFEREMOVE.BAT

echo off
echo SAFELY REMOVE
echo Starting Safely Remove
%windir%\system32\RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll

  • 0

Advertisements


#2
Ax238

Ax238

    Tech Staff

  • Technician
  • 1,323 posts
Welcome to Geeks to Go!

If you are trying to eject media from the your CD-ROM, you can use a VBS file for this. Save the following code as eject.vbs and then just run it using cscript.exe eject.vbs (or just double-click it if you want to test it).

Opening a CD drive:
Set oWMP = CreateObject("WMPlayer.OCX.7" )
Set colCDROMs = oWMP.cdromCollection

if colCDROMs.Count >= 1 then
		For i = 0 to colCDROMs.Count - 1
				colCDROMs.Item(i).Eject
		Next ' cdrom
End If

If this isn't what you're looking for, please let me know.

Ax
  • 0

#3
aikeru

aikeru

    New Member

  • Member
  • Pip
  • 8 posts
Mmmm sounds like it's not really "eject" but you want your USB devices "safely removed" automatically rather than having to do it yourself.

Here's a link that seems to have the information you need to get started:
http://portableapps.com/node/639

:)
  • 0

#4
phillpower2

phillpower2

    Mechanised Mod

  • Global Moderator
  • 24,749 posts

Redundant thread closed to prevent any further spam posts.


  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP