Jump to content

Detect USB devices connected.


 Share

Recommended Posts

I need to know which USB devices are plugged into the PC and save it in a file. Ini, which command does this?

Link to comment
Share on other sites

Something like this.

$vFile = FileOpen("usb.txt", 2)

Local $vObjWMI = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")

    $vObjItems = $vObjWMI.ExecQuery('SELECT * FROM Win32_USBHub')
    If IsObj($vObjItems) Then
        For $vObjItem In $vObjItems
                FileWriteLine($vFile, $vObjItem.Description & @CRLF)
                FileWriteLine($vFile, $vObjItem.DeviceID & @CRLF & @CRLF)
        Next
    EndIf

FileClose($vFile)

ShellExecute("usb.txt")

or if your specifically looking for USB Drives. maybe the below.

$vFile = FileOpen("usb.txt", 2)

Local $vObjWMI = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")

    $vObjItems = $vObjWMI.ExecQuery('SELECT * FROM Win32_DiskDrive')
    If IsObj($vObjItems) Then
        For $vObjItem In $vObjItems
            If StringInStr($vObjItem.Caption, "USB") Then
                FileWriteLine($vFile, $vObjItem.Caption & @CRLF)
                FileWriteLine($vFile, $vObjItem.DeviceID & @CRLF & @CRLF)
            EndIf
        Next
    EndIf

FileClose($vFile)

ShellExecute("usb.txt")
Edited by mrflibblehat

[font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font]

Link to comment
Share on other sites

I do not want to find drivers but human interface devices like keyboard, mouse and USB joystick.

Edited by Belini
Link to comment
Share on other sites

Have a look at >this post.

Or have a look at the below.

$vFile = FileOpen("usb.txt", 2)

Local $vObjWMI = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")

    $vObjItems = $vObjWMI.ExecQuery('SELECT * FROM Win32_PnPEntity')
    If IsObj($vObjItems) Then
        For $vObjItem In $vObjItems
            If StringInStr($vObjItem.PNPDeviceID, "HID\") Then
                FileWriteLine($vFile, $vObjItem.Name & @CRLF)
                FileWriteLine($vFile, $vObjItem.DeviceID & @CRLF & @CRLF)
            EndIf
        Next
    EndIf

FileClose($vFile)

ShellExecute("usb.txt")
Edited by mrflibblehat

[font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font]

Link to comment
Share on other sites

@mrflibblehat i tried everything that was posted there and could not identify the devices connected human interface on the PC, and the code you posted does not report that the device is connected.

Edited: This program shows http://www.nirsoft.net/utils/usb_devices_view.html more with Autoit not know how to do.

Edited by Belini
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...