[python-win32] Re: Dismounting a USB flash drive

Roger Upole rwupole at msn.com
Tue Jan 17 19:09:23 CET 2006

----- Original Message ----- 
From: "Paul Moore" <p.f.moore at gmail.com>
To: "Tim Golden" <mail at timgolden.me.uk>
Cc: <python-win32 at python.org>
Sent: Monday, January 16, 2006 12:20 PM
Subject: Re: [python-win32] Dismounting a USB flash drive

> On 1/13/06, Tim Golden <mail at timgolden.me.uk> wrote:
> > Well, according to this message:
> >
> > http://groups.google.com/group/microsoft.public.win32.programmer.wmi/msg/799622aef19f9a3c
> >
> > it's not supported in WMI. Which is a shame because
> > it would be quite useful. Maybe someone more win32
> > API-oriented might have some idea.
> Tim,
> Thanks for looking into this. I found a command line program (devcon,
> available from MS Knowledge Base article 311272 -
> http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272) which
> allows you to disable/remove/etc USB devices. But a few experiments
> made me realise that there's more to it than a simple "unplug" command
> - I managed to get all sorts of odd effects (drive "ejected" but still
> "plugged", through to the driver reinstalling itself when I inserted
> the drive again). I suspect that it's too easy to get things in a
> nasty state.
> So I'm sticking with a manual click on the tray icon, as the only way
> I'm not scared of, for now :-)
> Thanks for the help in any case,
> Paul.

I was pleasantly surprised to find that the source code for devcon.exe
is included with the Windows DDK.  Turns out it uses the SetupDI*
functions from SetupApi.h.  They look to be fairly involved for creating
a python interface.


More information about the Python-win32 mailing list