Jump to content
Sign in to follow this  
kzar

Getting drive and partition number of C:

Recommended Posts

kzar

Does anyone know how to get the Drive and Partition numbers of 'Drives' like C:?

I need to figure out if C: is the first partition on the drive its on or not.

Thanks, Kzar

Share this post


Link to post
Share on other sites
Joon

Partitions are start from count 0.

$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$WMIQuery = $objWMIService.ExecQuery ("SELECT * FROM Win32_LogicalDiskToPartition")
For $obj In $WMIQuery
    If StringInStr($obj.Dependent,"C:") Then
        MsgBox(0,"C Drive","C Drive is on partition #" & StringMid($obj.Antecedent,StringLen($obj.Antecedent)-1,1))
    EndIf
Next

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.