tags:

views:

559

answers:

1

How do I run the following WMI query, both programmatically to and as a one-shot deal? Can I use Visual Studio 2008, and if so what language and type of project do I setup? I'm a complete beginner at this so please provide details. Thanks!

SELECT * FROM Win32_USBControllerDevice
For Each as USBDevice
   ASSOCIATORS OF {Win32_PnPEntity.DeviceID="<USBDevice.Dependent>"}
    WHERE ResultClass = Win32_DiskDrive
   For Each as Drive
      ASSOCIATORS OF {Win32_DiskDrive.DeviceID="<Drive.DeviceID>"} 
       WHERE AssocClass = Win32_DiskDriveToDiskPartition
      For Each as Drive2Part
         ASSOCIATORS OF {Win32_DiskPartition.DeviceID="<Drive2Part.DeviceID>"} 
          WHERE AssocClass = Win32_LogicalDiskToPartition
         For Each as Disk2Part
            Win32_LogicalDisk = <Disk2Part.Dependent>
         End For
      End For      
   End For
End For

Here's the source of the query from CodeGuru.

+1  A: 

The WMI Code creator will create the snippets for you in a few languages. Its pretty handy for this kind of task.

StingyJack
I've already tried WMI Code Creator, as well Scriptomatic and WMI Tools, but none of them had a way for me to run the query above.
Abdullah Jibaly
A Query SELECTs data. The rest has iterations which are part of a programming language like VB or c#
StingyJack