Sign in to follow this  
Followers 0
kzar

Getting drive and partition number of C:

2 posts in this topic

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



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  
Followers 0