7

I have a loose connection somewhere... Every few minutes, I hear the device unplugged/plugged back in sound.

I can't see anything wrong and everything appears to be working.

I have tried looking in Device Manager, but, the noises seem to happen too fast or I just miss it.

I was wondering if anyone knows a way, or it would be better if you know a command that can simply tell me the last few device changes on my system?

1
  • William, your post read like a software recommendation question, so I made the change. Feel free to undo :)
    – Dave
    Jan 9, 2015 at 14:16

2 Answers 2

4

run EventGhost (http://www.eventghost.org/downloads/), when a device is attached, removed you see an event on the left side.

enter image description here

It includes a string with the hardware id. Now google for the ID to find the device.

1
  • I really wanted the script to work/find a way without needing apps, but this worked well. Thanks! Will mark as answer, but still hope a script/no software comes along in the future... Jul 11, 2015 at 16:57
2

VBScript

Some time ago I was troubleshooting a similar issue, and for the occasion I wrote a simple script. In order to run it, save the script in a new .vbs file, and run it through a command prompt:

cscript /nologo "X:\Path\to\script.vbs"

Here's the code:

If WScript.Arguments.Count = 0 Then
    maxEvents = 10
Else
    maxEvents = WScript.Arguments(0)
End If

Set wmiService = GetObject("winmgmts:\\.\root\cimv2") 
Set wmiQuery = wmiService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceDeletionEvent WITHIN 1" & _
    "WHERE TargetInstance ISA 'Win32_PnPEntity'")

separator = String(40, "-")

For i = 1 To maxEvents
    With wmiQuery.NextEvent.TargetInstance
        WScript.Echo separator & _
            vbCrLf & "Event " & i & " - " & Now & _
            vbCrLf & separator & _
            vbCrLf & .Name & _
            vbCrLf & .DeviceID
    End With
Next

How it works

An optional parameter is used to set the maximum amount of events to collect. If no amount is specified, it will record the first 10 events before quitting.

The script will then proceed to register an event provider targeting Plug and Play devices which get removed or unplugged. The polling interval is set to 1 second.

Every time there's a event notification, the script will print the results on screen, until the event amount is reached. The information includes: event number; date and time; device name and ID.

Further reading

1
  • Looks cool, but, can't seem to get it to work... Jul 6, 2015 at 19:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .