Click here to Skip to main content
16,020,249 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there a way to programmatically get the volume name associated with a hidden Windows disk partition? The hidden partition is found by querying Win32_DiskPartition, but I can't find a way to get the volume name of the partition. Diskpart lists them, so I know they exist. Note that I'm not asking for all volume names in a system, but the volume name associated with a specific (hidden) partition.

What I have tried:

DriveInfo.GetDrives doesn't return drives for volumes on hidden partitions. Querying Win32_LogicalDiskToPartition won't return any logical drives for hidden partitions, and there are no partition attributes in Win32_DiskPartition I can find that provide this information. Querying Win32_LogicalDisk doesn't return any logical disks for volumes on hidden partitions either.
Posted
Updated 3-Sep-16 16:16pm

1 solution

Hidden partitions are not mounted (no drive letter assigned) and can't be therefore accessed using any logical disk based Windows function.

When using Win32_DiskPartition you should have access to the label by the Name property. That is the text shown by diskpart in the "Label" column.
 
Share this answer
 
Comments
Maciej Los 2-Sep-16 5:02am    
5ed!
Member 12714049 5-Sep-16 23:38pm    
I really wish the Name property was the same one reported by Diskpart (and the one I assigned when I created the partition), but on my system the Name property returns something like "Disk #0, Partition #1".
Jochen Arndt 6-Sep-16 3:35am    
I'm sorry that my answer regarding the label is wrong.

A partition has no label. Only volumes have a label.

I see two methods to get the name:
1. Mount the volume temporarily to get the name
2. Read sectors from the partition to lookup the volume name (MFT record #3 with NTFS).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900