1.

Solve : Batch program for auto detection....?

Answer»

Can we write a batch program to auto detect the USB device that is when connected to computer ?

If possible please write the code.....
Thanx in advance....
http://support.microsoft.com/kb/310575/en-us

All the following information from the above site:

"Remove and reinstall all USB controllers
To remove and reinstall all USB controllers, follow these steps:1. Click Start, and click Control Panel, and then click Performance and Maintenance.
2. Click System, and then click the Hardware tab.
3. Click the Device Manager button.
4. Expand Universal Serial Bus controllers.
5. Right-click every device under the Universal Serial Bus controllers node, and then click Uninstall to remove them one at a time.
6. Restart the computer, and then reinstall the USB controllers.
7. Plug in the removable USB storage device, and then test to make sure that the issue is resolved."

please excuse bill, he has selective hearing "auto detect the USB device"

anywho,

with a bit of googling, i COULD not find any help with pure batch, but found with vbscript
Code: [Select]strComputer = "." '(Any computer name or address)
Set wmi = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set wmiEvent = wmi.ExecNotificationQuery("select * from __InstanceOperationEvent within 1 where TargetInstance ISA 'Win32_PnPEntity' and TargetInstance.Description='USB Mass Storage Device'")
Wscript.Echo("Waiting upon usb...")
While True
Set usb = wmiEvent.NextEvent()
Select Case usb.Path_.Class
Case "__InstanceCreationEvent" WScript.Echo("USB device found")
Case "__InstanceDeletionEvent" WScript.Echo("USB device REMOVED")
Case "__InstanceModificationEvent" WScript.Echo("USB device modified")
End Select
Wend
ran from command prompt:
Code: [Select]C:\tests>cscript /nologo drivedetect.vbs
Waiting upon usb...
USB device found
USB device modified
USB device removedQuote from: BatchFileBasics on October 24, 2009, 11:12:44 AM

Bill, The Original poster has selective hearing "auto detect the USB device"



"auto detection of a USB device" means the operating system automatically detects that a device has been been plugged into a USB port.

auto does not mean "audio"

A USB port is not a drive.

Your VBS code does nothing that the operating system has not covered.
-----------------------------------------

"USB is Short for Universal Serial Bus, an EXTERNAL bus standard that supports DATA transfer rates of 12 Mbps. A single USB port can be used to connect up to 127 peripheral devices, such as mice, modems, and keyboards. USB also supports Plug-and-Play installation and hot plugging." Troll Bill is active again.... Quote from: Salmon Trout on October 24, 2009, 05:23:04 PM
Bill is active again....

Please Salmon Trout I'm not trying to cause any trouble

Please tell me what is wrong with my post and I will rewrite or delete.

Thanks for your help.

------------------------------------------------
What is wrong with any of the following? :

"auto detection of a USB device" means the operating system automatically detects that a device has been been plugged into a USB port.

auto does not mean "audio"

A USB port is not a drive.

Your VBS code does nothing that the operating system has not covered.
BillRich: read the original post. Then read your first reply. State what relevance it has. It has none.

BFC answered the question he posed Re: detecting a USB drive when it is plugged in

Quote
"auto detection of a USB device" means the operating system automatically detects that a device has been been plugged into a USB port.

Yes. Very GOOD. have a cookie.

Quote
auto does not mean "audio"
the relevance of this being? BFC was stating that you, or more precisely, observing that you read "auto-detection of USB device" and instantly went about composing a random solution involving USB, without reading the full question.


Quote
A USB port is not a drive.

Again, congratulations on stating the obvious. Oh. here's a tip!: a piece of gum is not a weasel! BFC never said anything about drives... or ports, for that matter.

Quote
Your VBS code does nothing that the operating system has not covered.
Yes. It does. Does the operating System notify Batch Files when a USB device is inseted removed? No. Batch does not lend itself to that. So he scrounged up a VBS that does. The Operating System handles it but the request was for a way to detect when this happened.thank you for your post bc

but my abbr. name is BFB not BFC Quote from: BatchFileBasics on October 25, 2009, 10:47:55 AM

but my abbr. name is BFB not BFC

So it is...



Hi dudes........

What I'm asked ? What are you doing ?

I knew when a usb device is connected to the port the operating system will automatically detect it, but i didn't asked about it.

I asked you people is that write a "manual batch program" to automatically detect the usb when connected.

But you are...............Quote from: Vikram Varaprasad on October 26, 2009, 11:56:01 PM
Hi dudes........

What I'm asked ? What are you doing ?

I knew when a usb device is connected to the port the operating system will automatically detect it, but i didn't asked about it.

I asked you people is that write a "manual batch program" to automatically detect the usb when connected.

But you are...............

BFB provided this. It is IMPOSSIBLE via a pure batch file.Thank you , then where we can write that must support my question ?

BatchFileBasics' Post answers your question the best it is possible.ok, I'l try it. If any other solutions found please intimate me.

Thanks


Discussion

No Comment Found