From 79fac827a48fded94f27f387611208df61f4eaf5 Mon Sep 17 00:00:00 2001 From: Amal Cao Date: Thu, 12 Jan 2017 17:16:37 +0800 Subject: [PATCH] BUG FIX if the `objItem.Name` is not a string. --- listComPorts.vbs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/listComPorts.vbs b/listComPorts.vbs index 43c5bb7..cc27b61 100644 --- a/listComPorts.vbs +++ b/listComPorts.vbs @@ -42,9 +42,11 @@ Function GetComPorts() set objRgx = CreateObject("vbScript.RegExp") strDevName = objItem.Name objRgx.Pattern = "COM[0-9]+" - set objRegMatches = objRgx.Execute(strDevName) - if objRegMatches.Count = 1 then - portList.Add objRegMatches.Item(0).Value, objItem + if vbString = VarType(strDevName) then + set objRegMatches = objRgx.Execute(strDevName) + if objRegMatches.Count = 1 then + portList.Add objRegMatches.Item(0).Value, objItem + end if end if Next set GetComPorts = portList