Jump to content

Getting drive and partition number of C:


Recommended Posts

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...