Jump to content

Find Com Port in WMI Based on VID and PID


Recommended Posts

   I am at a loss. I have a virtial com port installed (COM35). if I look at the properties of it in Device Manage (Hardware IDs) the VID is 403 and the PID is 6001. The actual port number could change simply by unplugging the USB cable and plugging it in to a different USB port. The VID and PID, however, will stat the same.

   Is there any way to write a script that will look through the WIM (or registry for that fact) and look for the VID and PID and return the resultant ComPort? I.E. If the actual ComPort# changes I can still find the ComPort# based on VID and PID? 

 

Link to comment
Share on other sites

I think that this is what you are looking for:

http://www.codeproject.com/Tips/349002/Select-a-USB-Serial-Device-via-its-VID-PID

Not autoit but not hard to translate ;)

Hi!

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

  • Moderators

I was thinking something like this:

$wbemFlagReturnImmediately = "&h10"
$wbemFlagForwardOnly = "&h20"

$WMI = ObjGet("winmgmts:\\" & @ComputerName & "\root\WMI")
$aItems = $WMI.ExecQuery("SELECT * FROM MSSerial_PortName", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

   For $element In $aItems
       MsgBox(0, $element.Active, $element.PortName & "  " & $element.InstanceName)
    Next

Edit: Beat me to it, looks similar

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Pretty close JLogan3o13. I used "Select * from Win32_PnPEntity" and looked for "FTDIBUSVID_0403+PID_6001" in the DeviceID. Than I could parse the actual COMXX from the Name. That is also pretty much what that link you supplied did Nessie.

In both cases the "FTDIBUSVID_0403+PID_6001" is simply a USB to Sertal Converter. There could be a problem if there are two or more of them in the same computer in that you can't be sure what device is on the other end of that USB to Serial Converter.

A question.... if there are two or more of these present in a computer how does the WMI know which one was plugged in first... or does it?

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...