Re-detect a USB device without Unplugging and Replugging

G

Guest

synopsis :

Do we have a way to make windows detect a usb device once it is marked for
'safe removal'

Details :

I use windows xp with all latest patches,
i use a usb flash device to exchange data between work and home. Every time
i unplug the usb drive using the system tray icon, the un-mountings of the
usb device happens without any glitches. But i want the device to be
re-detected without a physical removal & plugging. i tried the "Add Hardware"
.. i fails with the below shown message

"Windows cannot use this hardware device because it has been prepared for
'safe removal', but it has not been removed from the computer. (Code 47)

To fix this problem, unplug this device from your computer and then plug it
in again."

though this pretty much explains what i should do,
is there a way to bypass this and re-detect my device.

Thanks
 
D

David Vair

Why would you use the safely remove device if you don't want to remove it? When you tell Windows
that you want to remove the device the system wil make it so that no information can be written to
it, that way nothing is lost. Only way to get it to be recognized is to remove and reinsert.
 
P

Pavel A.

Yes it's possible to clear the remove flag and reenumerate the device
using API, though I can't remember any ready tool for this.

--PA
 
U

Uwe Sieber

You could deactivate and then reactivate it instaed my means
of Microsoft DEVCON:
http://support.microsoft.com/kb/311272

Samples:
devcon disable USB\VID_067B*PID_2517\6*12115AD4*
devcon enable USB\VID_067B*PID_2517\6*12115AD4*

The device ID you can get by means of my tool
ListUsbDrives which comes with my USBDLM tool:
http://www.uwe-sieber.de/files/usbdlm.zip
Use the 'Ctrl DevID'.

The & character has a special meaning on the XP
commandline, so the best way is to replace it by
asterisks which DEVCON sees as wildcard for 'any char'.


Uwe
 
M

Mehrdad Mirreza

I needed this too for testing a launcher on my USB flash drive. As I used an old computer without front USB ports and I was too lazy to stand up each time and replug the memory stick I searched for a solution in web. All solutions I found need the Microsoft command line tool DevCon, which is not very straight forward to use, so I tried to find another one. It needs also some clicks, but does without extra tools:

1. push [win]+[Pause] to show the "System Properties" dialog or just pick it from the Control Panel

2. switch to Hardware tab and click on "Device Manager"

3. There you click on "Universal Serial Bus controllers" to open it

4. Below that you see 5 (maybe more or less) items called "USB root Hub". If you know which of them your device is connected to (i.e. through experience) right click it and select "disable", otherwise do that with all of them. WARNING: doing so will disconnect all connected USB devices!

5. Right click the disabled items and select "enable". Your devices are then detected again.

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com/default.aspx?ref=ng
 
H

Harry

On Jan 15, 10:52 pm, Mehrdad Mirreza wrote:
I needed this too for testing a launcher on my USB flash drive. As I
used an old computer without front USB ports and I was too lazy to stand
up each time and replug the memory stick I searched for a solution in
web. All solutions I found need the Microsoft command line tool DevCon,
which is not very straight forward to use [...]

Also, you are too lazy to figure it out yourself.

It works like a charm for my Kingston thumb drive.

D:\> devcon remove *Kingston*
USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_2.0&REV_PMAP
\001D92A85EAA5B8B040502A
D&0: Removed
1 device(s) removed.

<-- Windows explorer has the Kingston USB drive letter removed

D:\tmp5\i386> devcon rescan
Scanning for new hardware.
Scanning completed.

<-- Windows explorer has the Kingston USB drive letter
reappeared
 
M

Mehrdad Mirreza

@harry: Yes you are right, but I already wrote that I am lazy and my solution
was also for lazy people like me, who don't what to start a command session
and type that letters, but do just some clicks.

I must admit though, that your solution using wildcards has the great
benefit that it doesn't need the Windows Device Manager or nother tools to
get the device ID at all (like proposed by Uwe Sieber in the original thread
http://www.eggheadcafe.com/software/aspnet/29682755/redetect-a-usb-device-wi.aspx).
So it can be used to automate the "re-plugging" process using a batch file,
which then reduces the work to a doubleclick.

But I still remain with my solution as the easiest one :)

- MiMe

Harry said:
On Jan 15, 10:52 pm, Mehrdad Mirreza wrote:
I needed this too for testing a launcher on my USB flash drive. As I
used an old computer without front USB ports and I was too lazy to stand
up each time and replug the memory stick I searched for a solution in
web. All solutions I found need the Microsoft command line tool DevCon,
which is not very straight forward to use [...]

Also, you are too lazy to figure it out yourself.

It works like a charm for my Kingston thumb drive.

D:\> devcon remove *Kingston*
USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_2.0&REV_PMAP
\001D92A85EAA5B8B040502A
D&0: Removed
1 device(s) removed.

<-- Windows explorer has the Kingston USB drive letter removed

D:\tmp5\i386> devcon rescan
Scanning for new hardware.
Scanning completed.

<-- Windows explorer has the Kingston USB drive letter
reappeared
 
E

Engin Tarhan

As you have volunteered to give this pice of mind boggling wisdom without
being asked, I will also volunteer to give a piece of my mind, and I will
not be as gentle as the other fellas who have read your message and just
laughed it off.

You may think that being lazy is a quality to be proud of, but the
information your are giving is potentially dangerous! A number of clicks and
keypresses in a sensitive area of the OS which should be tinkered by people
who know what they're doing is not going to provide any benefit to the
mainstream of the computer users, the "normal" users as opposed to the lazy
one(s).

I believe that this fantastic way of showing your right earlobe with your
left hand will be adopted by no more than a handful of users who like to
think of themselves as being eccentric. If you were as clever as you're
lazy, you'd think of using a USB hub to bring that flash drive near your
hand.

Good luck
Engin
 
S

saad ali

can u plz tell me how to achieve this using a batch file.? thnx nd nice job.



Harry wrote:

Re: Eject and re-detect a usb drive without unplugging it
21-Jan-09

On Jan 15, 10:52=A0pm, Mehrdad Mirreza wrote:
On Jan 15, 10:52 pm, Mehrdad Mirreza wrote:

Also, you are too lazy to figure it out yourself.

It works like a charm for my Kingston thumb drive.

D:\> devcon remove *Kingston*
USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_2.0&REV_PMAP
\001D92A85EAA5B8B040502A
D&0: Removed
1 device(s) removed.

<-- Windows explorer has the Kingston USB drive letter removed

D:\tmp5\i386> devcon rescan
Scanning for new hardware.
Scanning completed.

<-- Windows explorer has the Kingston USB drive letter
reappeared

Previous Posts In This Thread:

Re-detect a USB device without Unplugging and Replugging
synopsis :

Do we have a way to make windows detect a usb device once it is marked for
'safe removal'

Details :

I use windows xp with all latest patches,
i use a usb flash device to exchange data between work and home. Every time
i unplug the usb drive using the system tray icon, the un-mountings of the
usb device happens without any glitches. But i want the device to be
re-detected without a physical removal & plugging. i tried the "Add Hardware"
... i fails with the below shown message

"Windows cannot use this hardware device because it has been prepared for
'safe removal', but it has not been removed from the computer. (Code 47)

To fix this problem, unplug this device from your computer and then plug it
in again."

though this pretty much explains what i should do,
is there a way to bypass this and re-detect my device.

Thanks

Why would you use the safely remove device if you don't want to remove it?
Why would you use the safely remove device if you don't want to remove it? When you tell Windows
that you want to remove the device the system wil make it so that no information can be written to
it, that way nothing is lost. Only way to get it to be recognized is to remove and reinsert.
--
Dave Vair
CNE, CNA, MCP, A+, N+


Yes it's possible to clear the remove flag and reenumerate the deviceusing
Yes it is possible to clear the remove flag and reenumerate the device
using API, though I cannot remember any ready tool for this.

--PA

You could deactivate and then reactivate it instaed my meansof Microsoft
You could deactivate and then reactivate it instaed my means
of Microsoft DEVCON:
http://support.microsoft.com/kb/311272

Samples:
devcon disable USB\VID_067B*PID_2517\6*12115AD4*
devcon enable USB\VID_067B*PID_2517\6*12115AD4*

The device ID you can get by means of my tool
ListUsbDrives which comes with my USBDLM tool:
http://www.uwe-sieber.de/files/usbdlm.zip
Use the 'Ctrl DevID'.

The & character has a special meaning on the XP
commandline, so the best way is to replace it by
asterisks which DEVCON sees as wildcard for 'any char'.


Uwe



Nanda wrote:

Eject and re-detect a usb drive without unplugging it
I needed this too for testing a launcher on my USB flash drive. As I used an old computer without front USB ports and I was too lazy to stand up each time and replug the memory stick I searched for a solution in web. All solutions I found need the Microsoft command line tool DevCon, which is not very straight forward to use, so I tried to find another one. It needs also some clicks, but does without extra tools:

1. push [win]+[Pause] to show the "System Properties" dialog or just pick it from the Control Panel

2. switch to Hardware tab and click on "Device Manager"

3. There you click on "Universal Serial Bus controllers" to open it

4. Below that you see 5 (maybe more or less) items called "USB root Hub". If you know which of them your device is connected to (i.e. through experience) right click it and select "disable", otherwise do that with all of them. WARNING: doing so will disconnect all connected USB devices!

5. Right click the disabled items and select "enable". Your devices are then detected again.

Re: Eject and re-detect a usb drive without unplugging it
Needed what?

--
Bob
http://www.kanyak.com

Re: Eject and re-detect a usb drive without unplugging it
@bob (Opinicus): This was a reply to
http://www.eggheadcafe.com/software/aspnet/29682755/redetect-a-usb-device-wi.aspx
... I don't know why it appears in this forum! What I needed is what is written
in the subject: "Eject and re-detect a usb drive without unplugging it"

:

Re: Eject and re-detect a usb drive without unplugging it
@harry: Yes you are right, but I already wrote that I am lazy and my solution
was also for lazy people like me, who don't what to start a command session
and type that letters, but do just some clicks.

I must admit though, that your solution using wildcards has the great
benefit that it doesn't need the Windows Device Manager or nother tools to
get the device ID at all (like proposed by Uwe Sieber in the original thread
http://www.eggheadcafe.com/software/aspnet/29682755/redetect-a-usb-device-wi.aspx).
So it can be used to automate the "re-plugging" process using a batch file,
which then reduces the work to a doubleclick.

But I still remain with my solution as the easiest one :)

- MiMe

:

As you have volunteered to give this pice of mind boggling wisdom without
As you have volunteered to give this pice of mind boggling wisdom without
being asked, I will also volunteer to give a piece of my mind, and I will
not be as gentle as the other fellas who have read your message and just
laughed it off.

You may think that being lazy is a quality to be proud of, but the
information your are giving is potentially dangerous! A number of clicks and
keypresses in a sensitive area of the OS which should be tinkered by people
who know what they're doing is not going to provide any benefit to the
mainstream of the computer users, the "normal" users as opposed to the lazy
one(s).

I believe that this fantastic way of showing your right earlobe with your
left hand will be adopted by no more than a handful of users who like to
think of themselves as being eccentric. If you were as clever as you're
lazy, you'd think of using a USB hub to bring that flash drive near your
hand.

Good luck
Engin

<Mehrdad Mirreza> wrote in message
Re: Eject and re-detect a usb drive without unplugging it
On Jan 15, 10:52=A0pm, Mehrdad Mirreza wrote:
On Jan 15, 10:52 pm, Mehrdad Mirreza wrote:

Also, you are too lazy to figure it out yourself.

It works like a charm for my Kingston thumb drive.

D:\> devcon remove *Kingston*
USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_2.0&REV_PMAP
\001D92A85EAA5B8B040502A
D&0: Removed
1 device(s) removed.

<-- Windows explorer has the Kingston USB drive letter removed

D:\tmp5\i386> devcon rescan
Scanning for new hardware.
Scanning completed.

<-- Windows explorer has the Kingston USB drive letter
reappeared


Submitted via EggHeadCafe - Software Developer Portal of Choice
The Software Project Loan Shark!
http://www.eggheadcafe.com/tutorial...d-3d73e47db1d5/the-software-project-loan.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top