How can I eject a memory card or other removable media from the command line (without removing the reader)?

1

I can eject a network drive using net use X: /DELETE but when I try to use this same command on removable media I get an error:

The network connection could not be found.

More help is available by typing NET HELPMSG 2250.

Yes, obviously it isn't a network connection, so how do I eject the device from a script?

Michael

Posted 2013-04-24T04:58:07.927

Reputation: 2 242

1This is not a duplicate of the other question. That question is about removing a USB device; this is about ejecting a removable media. Using the solutions in the other question will remove the drive which is not the same as ejecting the media in the drive. If you eject a memory-card from a card-reader, then you can take the card out and plug another one in and start using it. If you remove it, the whole reader will be removed and it will be a real pain to get it back. – Synetech – 2016-05-01T22:59:08.673

Answers

2

There doesnt appear to be a built in Windows command to do this. There may be scripting functionality in VBScript or PowerShell, but I didnt see any.

However, you are not the only person to ask this. I found this in a quick Google search. Some C++ code to compile to give you a CLI command to eject media. Look at the first answer to the question for a link to the code.

Here is a precompiled program that does something similar.

Keltari

Posted 2013-04-24T04:58:07.927

Reputation: 57 019

1It looks like the Freeject tool actually does eject removable media without removing the drive. Finally a solution. Thanks! – Synetech – 2016-05-01T22:57:54.400

Wow, I'm surprised this isn't possible without external software. I would rather just pull the card than have to go to all this trouble. – Michael – 2013-04-24T05:07:29.853

just be sure to enable "quick removal" so you dont corrupt your data – Keltari – 2013-04-24T05:15:48.793

i'll make sure that's enabled. however, it should be safe anyway if i'm not writing the drive, right? i'm basically just running an asset import script which only reads data off the device. – Michael – 2013-04-24T05:17:46.207

If you arent writing to the drive, in theory the cache doesnt need to be flushed... but you never know... better safe than sorry, right? – Keltari – 2013-04-24T05:19:37.140