alansch64 Posted September 11, 2010 Posted September 11, 2010 Hello, After hours of searching with no luck, I turn to you for my question. I'm new to autoit and scripting and recently learning from examples found here in the forum. A true gold mine ! The following script will return the property name of any instance of PNPDeviceID containing "FTDI" (which is a chip used for (USB/RS232) ) Of course on some computer this property name does not exist. I need to inform the user that the device was not found. My Question: How can I test "$oItem.Name" to see if it's content is empty and send out a message saying that no device was found ? I've tried to assign a variable to be able to test it..etc.. but that won't do. I'm certainly missing on an easy thing that comes from my lack of programing knowledge.. . so thanks in advance for your help. Local $wbemFlagReturnImmediately= 0x10 Local $wbemFlagForwardOnly = 0x20 Local $h_wbemFlags = $wbemFlagReturnImmediately + $wbemFlagForwardOnly $sWMIService = "winmgmts:\\" & @ComputerName & "\root\CIMV2" $objWMIService = ObjGet($sWMIService) If IsObj($objWMIService) Then $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PnpEntity WHERE PNPDeviceID LIKE '%FTDI%'", "WQL", $h_wbemFlags) If IsObj($oItem) Then For $oItem in $colItems MsgBox(64, "Win32_PnpEntity", $oItem.Name) Next Else MsgBox(16, "Error", "Failed to get Win32_PnpEntity.") EndIf Else MsgBox(4096, "ERROR", "Failed to connect to WMI at: " & $sWMIService) EndIf
wakillon Posted September 11, 2010 Posted September 11, 2010 Try If IsObj($colItems) Then instead of If IsObj($oItem) Then AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
alansch64 Posted September 11, 2010 Author Posted September 11, 2010 Try If IsObj($colItems) Theninstead of If IsObj($oItem) ThenThanks !I was missing the If IsObj to test the value...Works now !!
wakillon Posted September 11, 2010 Posted September 11, 2010 Glad to help you ! AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now