Reputation: 53
I want to get the drive letter from Partition Index.
wmic path Win32_LogicalDiskToPartition WHERE Antecedent='Win32_DiskPartition.DeviceID=\'Disk #1 AND Partition #0\'' Get Dependent
Result: No Instance(s) Available
Upvotes: 0
Views: 921
Reputation: 53
SETLOCAL
FOR /F "delims=" %%a in ('wmic path Win32_DiskPartition WHERE (DeviceID="Disk #0, Partition #1") Assoc:list /AssocClass:Win32_LogicalDiskToPartition /ResultRole:Dependent ^| Find "Caption="') DO (
ECHO %%a
)
Pause
It is show empty.
I need result as: Caption=C:
Upvotes: 0
Reputation: 38579
The following should output your information, you'd obviously need to parse it further to select the drive letter from that.
WMIC Partition Where (DeviceID="Disk #1, Partition #0") Assoc /ResultRole:Dependent 2>NUL
Alternatively:
WMIC Partition Where (DeviceID="Disk #1, Partition #0") Assoc /AssocClass:Win32_LogicalDiskToPartition 2>NUL
Upvotes: 1