Bodman 0 Posted October 31, 2011 Share Posted October 31, 2011 Hi All, I have generated a WMI query using scriptomatic, but im trying to only output the information after the Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_152D&PID_2338\\ So Basically I want to run my script and all to appear is the answer D57CA7226232 Any help greatly appreciated, I've gone around and around trying to solve this AccessState: Antecedent: \\COMPUTER\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_283A&SUBSYS_101017AA&REV_02\\3&18D45AA6&0&D7"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_152D&PID_2338\\D57CA7226232"NegotiatedDataWidth: NegotiatedSpeed: NumberOfHardResets: NumberOfSoftResets ; Generated by AutoIt Scriptomatic $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_USBControllerDevice", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "Dependent: " & $objItem.Dependent & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_USBControllerDevice" ) Endif ThanksBod Link to post Share on other sites
Spiff59 55 Posted October 31, 2011 Share Posted October 31, 2011 (edited) Can we assume that what you want always follows the last backslash? If so... ; Generated by AutoIt Scriptomatic $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_USBControllerDevice", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = StringTrimRight($objItem.Dependent, 1) ; trim trailing quote $Output = "Dependent: " & StringTrimLeft($Output, StringInStr($Output, "\", 2, -1)) & @CRLF Msgbox(1,"WMI Output",$Output) Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_USBControllerDevice" ) Endif Edited October 31, 2011 by Spiff59 Link to post Share on other sites
Bodman 0 Posted November 1, 2011 Author Share Posted November 1, 2011 Thanks for that, the script actually outputs the whole of the USBControllerDevice (22 lines see below) but I only want the information for 1 device (Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_152D&PID_2338\\ ) Any idea how I can limit it to that. Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\ROOT_HUB\\4&34787A46&0"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\ROOT_HUB\\4&1F0931D3&0"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\ROOT_HUB\\4&157829D5&0"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\ROOT_HUB\\4&2E050B29&0"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\ROOT_HUB\\4&9BB4E4F&0"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\ROOT_HUB20\\4&1FA45A99&0"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_0424&PID_2524\\5&2B86C837&0&3"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_050D&PID_3201\\6&2A72F29A&0&1"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="HID\\VID_050D&PID_3201&COL01\\7&1576BE94&0&0000"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="HID\\VID_050D&PID_3201&COL02\\7&1576BE94&0&0001"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_045E&PID_0040\\6&2A72F29A&0&4"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="HID\\VID_045E&PID_0040\\7&3DA0528&0&0000"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_045E&PID_00B0\\6&2A72F29A&0&3"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_045E&PID_00B0&MI_00\\7&1F5C99AB&0&0000"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="HID\\VID_045E&PID_00B0&MI_00\\8&ADDDB07&0&0000"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_045E&PID_00B0&MI_01\\7&1F5C99AB&0&0001"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="HID\\VID_045E&PID_00B0&MI_01&COL01\\8&22A1674C&0&0000"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="HID\\VID_045E&PID_00B0&MI_01&COL02\\8&22A1674C&0&0001"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_13B1&PID_0023\\5&2B86C837&0&4"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="{5D624F94-8850-40C3-A3FA-A4FD2080BAF3}\\VWIFIMP\\6&1DBA515D&0&02"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\ROOT_HUB20\\4&88316C0&0"Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_0000&PID_0000\\5&2931F589&0&4" Thanks in advance Bod Link to post Share on other sites
roofninja 0 Posted November 1, 2011 Share Posted November 1, 2011 Save the 22 line output as a file. Ether Read each line or if you know exactly what line it is everytime, then msgbox the what you want from the line. RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!! Link to post Share on other sites
Zedna 376 Posted November 1, 2011 Share Posted November 1, 2011 Thanks for that, the script actually outputs the whole of the USBControllerDevice (22 lines see below) but I only want the information for 1 device (Dependent: \\COMPUTER\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_152D&PID_2338\\ ) Any idea how I can limit it to that. I thought it should be something like this $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_USBControllerDevice WHERE Dependent LIKE '%VID_152D&PID_2338%' ", "WQL", ... But when I try to run this it returns nothing, so maybe there is needed some tweaking ... Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to post Share on other sites
Bodman 0 Posted November 3, 2011 Author Share Posted November 3, 2011 I thought it should be something like this $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_USBControllerDevice WHERE Dependent LIKE '%VID_152D&PID_2338%' ", "WQL", ... But when I try to run this it returns nothing, so maybe there is needed some tweaking ... Ive tried every permutation of this that I can and unfortunately I still cant get any output although it definitely seems on the right tracks Link to post Share on other sites
Zedna 376 Posted November 3, 2011 Share Posted November 3, 2011 (edited) I thought it should be something like this $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_USBControllerDevice WHERE Dependent LIKE '%VID_152D&PID_2338%' ", "WQL", ... But when I try to run this it returns nothing, so maybe there is needed some tweaking ... According to MSDN http://msdn.microsoft.com/en-us/library/windows/desktop/aa394505(v=vs.85).aspx Dependent property is not type string but Reference to the CIM_LogicalDevice instance. That's why WHERE + LIKE doesn't work. Edited November 3, 2011 by Zedna Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to post Share on other sites
Bodman 0 Posted November 3, 2011 Author Share Posted November 3, 2011 Thanks, I actually got it working by using a different WMI Class SELECT * FROM Win32_PnPEntity WHERE DeviceID LIKE '%VID_152D&PID_2338%' But I have found that when I run it on some of our computers I just get the answer D57CA7226232 but on others I get 2 answers D57CA7226232 and blank (Empty Message box) This is because on those clients I have VID_152D&PID_2338 and also VID_152D&PID_2338&MI_00 how do I ignore the null value or the data from VID_152D&PID_2338&MI_00. I have tried NOT LIKE in the Query, but it dosnt like that ; Generated by AutoIt Scriptomatic $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PnPEntity WHERE DeviceID LIKE '%VID_152D&PID_2338%' ", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) body() func body() If IsObj($colItems) then For $objItem In $colItems ConsoleWrite ($Output)$Output = StringTrimRight($objItem.DeviceID, 1) ; trim trailing quote $Output = "" & StringTrimLeft($Output, StringInStr($Output, "\", 2, -1)) & @CRLF Msgbox(1,"WMI Output",$Output) Next Endif endfunc Link to post Share on other sites
rover 56 Posted November 3, 2011 Share Posted November 3, 2011 Thanks, I actually got it working by using a different WMI Class But I have found that when I run it on some of our computers I just get the answer D57CA7226232 but on others I get 2 answers D57CA7226232 and blank (Empty Message box) This is because on those clients I have VID_152D&PID_2338 and also VID_152D&PID_2338&MI_00 how do I ignore the null value or the data from VID_152D&PID_2338&MI_00. I have tried NOT LIKE in the Query, but it dosnt like that escape the backslash after VID_152D&PID_2338 with a backslash $colItems = $objWMIService.ExecQuery("SELECT DeviceID FROM Win32_PnPEntity WHERE DeviceID LIKE '%VID_152D&PID_2338\\%' ", "WQL", _ I see fascists... Link to post Share on other sites
Bodman 0 Posted November 4, 2011 Author Share Posted November 4, 2011 Thanks for the help everyone, that sorted it, Really appreciate it Bod Link to post Share on other sites
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