Twi*_*ech 2 windows hard-drive windows-pe wmic
我正在寻找一种方法来列出驱动器及其上的分区。具体来说,我希望提示用户格式化驱动器,并且我想向他们显示现有的分区,以便他们可以确认他们的选择。
我找到了 wmic 命令来列出磁盘驱动器、逻辑磁盘、分区和卷,但我找不到将卷关联到物理驱动器的方法。
我还发现了一个 powershell 脚本可以完成我想要的任务。该脚本使用 gwmi,我不知道如何将命令转换为 wmic。 http://jrich523.wordpress.com/2011/12/12/using-wmi-to-link-a-disk-volume-to-a-physical-disk-with-powershell/
有没有办法使用 wmic 获取物理磁盘上的卷列表?
该wmic
命令与 VB 或 PowerShell 语法略有不同。
相关语法为wmic
:
wmic <command> where <conditional> Assoc /assocclass:<class>
Run Code Online (Sandbox Code Playgroud)
具体解决上述任务:
wmic DiskDrive where "DeviceID='\\\\.\\PHYSICALDRIVE<disk_index>'" Assoc /assocclass:Win32_DiskDriveToDiskPartition
Run Code Online (Sandbox Code Playgroud)
将返回驱动器上具有给定索引的分区。
wmic partition where (DeviceID="<partition_id>") assoc /assocclass:Win32_LogicalDiskToPartition
Run Code Online (Sandbox Code Playgroud)
将返回具有给定 ID 的分区上的卷。
归档时间: |
|
查看次数: |
17697 次 |
最近记录: |