Eject a Removable USB drive

Aaron Brady castironpi at gmail.com
Mon Mar 9 19:14:41 EDT 2009


On Mar 9, 6:08 pm, Mark Hammond <skippy.hamm... at gmail.com> wrote:
> On 10/03/2009 8:20 AM, Rickey, Kyle W wrote:
>
> > Thanks for the link! That code has got me on the right track. I've
> > almost got it working with one small kink.
>
> > After the code runs my drive still shows up on Windows Explorer but as a
> > removable drive. If I try to double click on it, it tells me to insert a
> > disk (see screenshot).
>
> > So it seems my code is unmounting my volume, but not the actual device.
> > Any ideas? I've attached the code I've got so far.
>
> Adding the following after your eject code runs:
>
> from win32com.shell import shell, shellcon
> shell.SHChangeNotify(shellcon.SHCNE_DRIVEREMOVED, shellcon.SHCNF_PATH,
> "F:\\")
>
> seems to work for me (well - I actually did the above interactively
> after your code ran, and the disk magically vanished from explorer...)

Yay, magically!  import crystalball?



More information about the Python-list mailing list