windows 如何使用CMD获取硬盘信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26729187/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:48:07  来源:igfitidea点击:

How can get Hard Disk Information Using CMD

windowscmdcommandadminhard-drive

提问by Lokesh Kumar

I am use this command for finding hard disk in formation "wmic diskdrive" but i insert a external device like hard disk or pan drive, this command is provide information of external hard disk or pan drive. so how can find internal hard disk information where system window installed.

我使用此命令查找硬盘信息“wmic diskdrive”,但我插入了硬盘或盘驱动器等外部设备,此命令提供外部硬盘或盘驱动器的信息。那么如何找到安装系统窗口的内部硬盘信息。

回答by Santhosh

It is off topic here , though you can get the info using following cmd

它在这里是题外话,但您可以使用以下方法获取信息 cmd

wmic logicaldisk

or ,

或者 ,

diskpartthen list volume

diskpart然后 list volume

回答by Stephan

"find internal hard disk information where system window installed."

“查找安装系统窗口的内部硬盘信息。”

wmic logicaldisk where caption="%systemdrive%" get /value

Note: logicaldiskis a partition on an physical drive (the only one, if you are lucky, but there may be more partitions on the same physical drive)

注意:logicaldisk是一个物理驱动器上的分区(唯一一个,如果幸运的话,但同一个物理驱动器上可能会有更多的分区)

回答by Paul Williams

The PowerShell way is:

PowerShell 的方式是:

PS C:\> $Disk = Get-WmiObject -Class Win32_logicaldisk -Filter "DeviceID = 'C:'"
PS C:\> $DiskPartition = $Disk.GetRelated('Win32_DiskPartition')
PS C:\> $DiskDrive = $DiskPartition.GetRelated('Win32_DiskDrive')
PS C:\> $DiskDrive.Size
1024203640320

This is nicely explained here.

这很好地解释了here

But the original question was about how to do this with CMD.

但最初的问题是关于如何使用 CMD 做到这一点。

C:\>wmic diskdrive get model,name,size
Model                       Name                Size
SAMSUNG MZVLB1T0HALR-000L7  \.\PHYSICALDRIVE0  1024203640320
Generic- SD/MMC USB Device  \.\PHYSICALDRIVE1

Given a choice, I prefer to use the PowerShell method, starting from the drive letter and working up to the physical disk. It's rather verbose but it gives a unique answer, and requires no knowledge of the system. (Some devices have many physical disks and it can get confusing.)

如果有选择,我更喜欢使用 PowerShell 方法,从驱动器号开始,一直到物理磁盘。它相当冗长,但它给出了一个独特的答案,并且不需要系统知识。(有些设备有很多物理磁盘,这可能会让人感到困惑。)