Jump to content
Sign in to follow this  

Help with "WMI Query Language"

Recommended Posts



What I want to do Is to get the driveletter for a USB-device with a specific Device ID (not to confuse with Volume ID)

First I query WIN32_DISKDRIVE with this query select DeviceID from Win32_DiskDrive where PNPDeviceID like '%0000167A6774E238%' (that long number was the DeviceID )

So now I know its "PhysicalDrive3" (just for this example) and then I was thinking to translate this to a partition via WIN32_DiskDriveToDiskPartition

(PhysicalDrive3 should be selected from column Antecedent and then if i read the Dependent column I would get the partition "Disk #3, Partition #0")

...with a query like select * from win32_DiskdriveToDiskPartition (but when I use "where" in the later query I always get an error if I try to use "where .... like" instead of "where .... = " ) ...not sure why

And to finish it of when/if I get the partition the I was thinking to query WIN32_LogicalDiskToPartition

(search the partition "Disk #3, Partition #0" in Antecendent and get the driveletter out from Dependent "M:"

...with a query something like select * from win32_LogicalDiskToPartition

So I know how I could get the information I want by using 3 queries.... If I look at the result and manually use that information to feed the next query.

If someone here is familiar with "WMI Query Language" or SQL you might be able to tell me how to make this in to ONE advanced query that gives me the driveletter if i know the device ID

Any help appreciated ...kinda stuck

Share this post

Link to post
Share on other sites

Found the answer myself after some hours spent with mr google... had to use some "ASSOCIATORS OF" (had no idea that they existed) queries instead of SELECT

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.