Skip to content

Instantly share code, notes, and snippets.

@dzzie
Created August 31, 2020 10:19
Show Gist options
  • Save dzzie/692eebdd429ee63cacdcb82021a6668e to your computer and use it in GitHub Desktop.
Save dzzie/692eebdd429ee63cacdcb82021a6668e to your computer and use it in GitHub Desktop.
'save this file as enumSerialPorts.vbs
'open a command shell,
'change directory to the same folder the vbs script is in (cd command)
'type in: cscript enumSerialPorts.vbs
'if WMI is working it should print out any connected COM port devices like arduinos.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_SerialPort", , 48)
For Each objItem In colItems
WScript.echo objItem.DeviceID & " " & objItem.Description
Next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment