LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

eject USB device programatically

Highlighted
I have an application which runs modal and hides the OS, this application requires the user to insert and remove usb flash drives.  Is there any api call to remove a USB drive?  I am able to find the drives with a search of D-Z:\ but I need to be able to eject the drive with a button on the Front panel.
 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 1 of 12
(2,862 Views)
Highlighted

Try this article:

Community Admin Note:  The article link has been removed due to invalid information.

 
0 Kudos
Message 2 of 12
(2,850 Views)
Highlighted
Thanks I will give it a try.
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 12
(2,826 Views)
Highlighted

I know this is an old post, but this is what I am looking for.

I tried this with Win7 and am not convinced it works.  The program responds that the drive was ejected, but the computer can still access the drive.  Do you know if there is an updated version for Win7?

Thanks.




metzler CLAD
0 Kudos
Message 4 of 12
(1,978 Views)
Highlighted

@metzler wrote:

I know this is an old post, but this is what I am looking for.

I tried this with Win7 and am not convinced it works.  The program responds that the drive was ejected, but the computer can still access the drive.  Do you know if there is an updated version for Win7?

Thanks.


Plug-n-Pray. has gotten a bit better in the last 9 years.  With Win 7 and later my experience has been something like " If the Device can't be hot swapped on a USB port - Trash the obsolete device."  Not a common point of view.  Realistic though!

 

Lets look at the phy layer on a modern USB device.  Yup, "The Physical Layer"  all four connections!  Take a close look.  did you notice that two of the four conductors are just a bit shorter than the others?  Data lines are disconnected before 5V and Gnd. 5V and Gnd are connected before data lines.  Works like a charm.

"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 12
(1,950 Views)
Highlighted

@JÞB wrote:

@metzler wrote:

I know this is an old post, but this is what I am looking for.

I tried this with Win7 and am not convinced it works.  The program responds that the drive was ejected, but the computer can still access the drive.  Do you know if there is an updated version for Win7?

Thanks.


Plug-n-Pray. has gotten a bit better in the last 9 years.  With Win 7 and later my experience has been something like " If the Device can't be hot swapped on a USB port - Trash the obsolete device."  Not a common point of view.  Realistic though!

 

Lets look at the phy layer on a modern USB device.  Yup, "The Physical Layer"  all four connections!  Take a close look.  did you notice that two of the four conductors are just a bit shorter than the others?  Data lines are disconnected before 5V and Gnd. 5V and Gnd are connected before data lines.  Works like a charm.


I think the main reason for 'safely removing hardware' is in the case of USB memory sticks where a write operation might not have completed if you just pull out the drive randomly. I think it's gotten a bit better in newer versions of windows (e.g. turning off/reducing write caching) but obviously if you were copying/writing to a file, the 'safely remove hardware' is a check to make sure any outstanding writes are complete.

 

Reference:

f78cdf98acb28496ba3a7499ecfa2ef00ef00a4003edb4d94564165e622ed518.jpg


LabVIEW Champion, CLA, CLED, CTD
MediaMongrels Ltd. - NI Alliance Partner (blog)
Message 6 of 12
(1,914 Views)
Highlighted
Thanks for the information and quick response. So, as long as my LabView program writes to the USB drive and provides ample time afterwards, the computer should no longer be writing to the drive, and I can issue instructions to the user to remove the USB drive? If correct, is there a way to determine how long is ample time to write to the drive? I am worried that Windows might (quickly) write to it, then access every couple of minutes for some (stupid) reason.



metzler CLAD
0 Kudos
Message 7 of 12
(1,885 Views)
Highlighted
Message 8 of 12
(1,874 Views)
Highlighted

@OEM_Dev wrote:

You're probably OK by default

 

 

See

http://www.pcworld.com/article/254868/safely_remove_usb_drives_just_by_unplugging_them.html


nice link!

"Should be" isn't "Is" -Jay
Message 9 of 12
(1,862 Views)
Highlighted
Thanks, I will assume everything is okay with removing it after writing a small file. .



metzler CLAD
0 Kudos
Message 10 of 12
(1,817 Views)