Safe removal of a USB Drive or Memory Stick - Programatically

  • Thread starter Thread starter ChrisR
  • Start date Start date
C

ChrisR

How can i ensure the safe removal of a USB drive or memory stick from
Windows XP and WIndows 2003 server safely - from my own program without
the user having to click on the icon in the systray. The SYNC.EXE
program from sysinternals only appears to do half the job. I.e., you
still get a 'transaction log corrupted' event message when you remove a
drive after running sync.exe.
If you don't run sync.exe you usually get 2 'transaction log corrupted'
event messages.
 
In device manager, there is an option for the removable disks "optimize for
safe removal" (enabled by default for XP and 2003 server). That means, once
you have copied the files, you can unplug the memmory stick and there will
be no data loss.


:
| How can i ensure the safe removal of a USB drive or memory stick from
| Windows XP and WIndows 2003 server safely - from my own program without
| the user having to click on the icon in the systray.

Well if "optimize for safe removal" is enabled, just show a green indicator,
meaning "I am not currently using the memory stick" (it is safe to be
removed). RED: "Disk is in use" (do not remove).


| The SYNC.EXE
| program from sysinternals only appears to do half the job. I.e., you
| still get a 'transaction log corrupted' event message when you remove a
| drive after running sync.exe.
| If you don't run sync.exe you usually get 2 'transaction log corrupted'
| event messages.
|
 
George said:
In device manager, there is an option for the removable disks "optimize for
safe removal" (enabled by default for XP and 2003 server). That means, once
you have copied the files, you can unplug the memmory stick and there will
be no data loss.

That's what MS wrote into the dialog window, so everyone
thinks that it's true. But all my test showed that it's at
least misleading. It most cases it's just wrong.

In the case we talk about here we have an NTFS formatted drive.
Here there is always a write cache activated even "optimize for
safe removal" is selected.

Here my collected results:
http://www.uwe-sieber.de/usbstick_e.html


Uwe
 
ChrisR said:
How can i ensure the safe removal of a USB drive or memory stick from
Windows XP and WIndows 2003 server safely - from my own program without
the user having to click on the icon in the systray. The SYNC.EXE
program from sysinternals only appears to do half the job. I.e., you
still get a 'transaction log corrupted' event message when you remove a
drive after running sync.exe.

My tool RemoveDrive can do that:
http://www.uwe-sieber.de/usbstick_e.html#save_removal

I've made a demo project that shows how to do that in your
own project:
http://www.codeproject.com/system/RemoveDriveByLetter.asp


Uwe
 
Back
Top