I don't think it's the loop, but here's the code:
#!/usr/local/perl -w use Win32::OLE('in'); use strict; # Variables my @devIds = (); my @devPnPDevIds = (); my $wmiService = Win32::OLE->GetObject("winmgmts:\\\\.\\root\\cimV2"); my $colDisks = $wmiService->ExecQuery("Select * from CIM_LogicalDevice +"); foreach my $obj ( in( $colDisks ) ) { if($obj->{DeviceID} =~ /.*VID_0AF0&PID_(\d*)&MI_\d*\\(\d&.*&\d&).*/i +) { my $tmpId = $obj->{DeviceID}; $tmpId =~ s/\\/\\\\/g; my $tmpPnpId = $obj->{PNPDeviceID}; $tmpPnpId =~ s/\\/\\\\/g; push(@devIds,$tmpId); push(@devPnPDevIds,$tmpPnpId); } } for(my $tel = 0; $tel < @devPnPDevIds; $tel++) { print "The detected PNP device ID is: ".$devPnPDevIds[$tel]."\n"; my $deviceID = $devPnPDevIds[$tel]; my $subDevices = $wmiService->ExecQuery('ASSOCIATORS OF {Win32_PnPEn +tity.DeviceID="'.$deviceID.'"} WHERE AssocClass=Win32_PnPDevice'); foreach my $subDevProp ( in( $subDevices ) ) { print "CreationClassName: ".$subDevProp->{CreationClassName}."\n"; print "Caption: ".$subDevProp->{Caption}."\n"; print "Description: ".$subDevProp->{Description}."\n"; print "DeviceID: ".$subDevProp->{DeviceID}."\n"; print "HardwareID: ".$subDevProp->{HardwareID}."\n"; print "PNPDeviceID: ".$subDevProp->{PNPDeviceID}."\n"; print "Service: ".$subDevProp->{Service}."\n"; print "SystemName: ".$subDevProp->{SystemName}."\n"; } }
My guess is I'm missing some bus relations which I can't retrieve with "Win32_Bus". (The IDs I get with this call are not unique, hence I cann't use it).

Am I missing something in this query?

Update: Guess I'm looking for a logical bus, not a phisical one. But were (and how) to find it...?


Update:
Win32_Bus retrieves the phisical Bus devices. This is not the thing I needed, since more devices are connected on 1 physical bus.
I did found a solution however.
I have to querry the PDO (Physical Device Object). These can give me enough date (along with the deviceID) to combine all instances, created by the drivers, that belong to a single device.

In reply to Re^2: WMI: Bus relations by jschollen
in thread WMI: Bus relations by jschollen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.