是否有内置的 Windows 实用程序可以显示类似磁盘管理 MMC 的信息?

是否有内置的 Windows 实用程序可以显示类似磁盘管理 MMC 的信息?

我正在寻找一个内置的 Windows XP/Server 2003 实用程序,它可以提取驱动器信息,类似于磁盘管理 mmc 显示的内容,包括容量和可用空间。有什么想法吗?

Diskpart 似乎没有报告可用空间,磁盘管理似乎没有“导出到文本”功能。有什么想法吗?

请注意,我并不需要任何第三方工具推荐。如果它不是 Windows 内置的,我可能需要编写脚本。

答案1

对于 Windows XP 和 Server 2003,使用 fsutil 命令

C:\Documents and Settings\administrator>fsutil volume diskfree C:
Total # of free bytes        : 14056869888
Total # of bytes             : 21459722240
Total # of avail free bytes  : 14056869888

答案2

DISKPART 将在卷级别显示此信息(仅适用于 Windows Vista)

DISKPART> detail volume

  Disk ###  Status      Size     Free     Dyn  Gpt
  --------  ----------  -------  -------  ---  ---
* Disk 0    Online        75 GB      0 B

Read-only              : No
Hidden                 : No
No Default Drive Letter: No
Shadow Copy            : No
Dismounted             : No
BitLocker Encrypted    : No

Volume Capacity        :   74 GB
Volume Free Space      :    8 GB

答案3

关于逻辑磁盘您可能需要的每一点信息:

On Error Resume Next
Dim strComputer
Dim objWMIService
Dim propValue
Dim objItem
Dim SWBemlocator
Dim UserName
Dim Password
Dim colItems

strComputer = "."
UserName = ""
Password = ""
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",UserName,Password)
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk",,48)
For Each objItem in colItems
    WScript.Echo "Access: " & objItem.Access
    WScript.Echo "Availability: " & objItem.Availability
    WScript.Echo "BlockSize: " & objItem.BlockSize
    WScript.Echo "Caption: " & objItem.Caption
    WScript.Echo "Compressed: " & objItem.Compressed
    WScript.Echo "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode
    WScript.Echo "ConfigManagerUserConfig: " & objItem.ConfigManagerUserConfig
    WScript.Echo "CreationClassName: " & objItem.CreationClassName
    WScript.Echo "Description: " & objItem.Description
    WScript.Echo "DeviceID: " & objItem.DeviceID
    WScript.Echo "DriveType: " & objItem.DriveType
    WScript.Echo "ErrorCleared: " & objItem.ErrorCleared
    WScript.Echo "ErrorDescription: " & objItem.ErrorDescription
    WScript.Echo "ErrorMethodology: " & objItem.ErrorMethodology
    WScript.Echo "FileSystem: " & objItem.FileSystem
    WScript.Echo "FreeSpace: " & objItem.FreeSpace
    WScript.Echo "InstallDate: " & objItem.InstallDate
    WScript.Echo "LastErrorCode: " & objItem.LastErrorCode
    WScript.Echo "MaximumComponentLength: " & objItem.MaximumComponentLength
    WScript.Echo "MediaType: " & objItem.MediaType
    WScript.Echo "Name: " & objItem.Name
    WScript.Echo "NumberOfBlocks: " & objItem.NumberOfBlocks
    WScript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
    for each propValue in objItem.PowerManagementCapabilities
        WScript.Echo "PowerManagementCapabilities: " & propValue
    next
    WScript.Echo "PowerManagementSupported: " & objItem.PowerManagementSupported
    WScript.Echo "ProviderName: " & objItem.ProviderName
    WScript.Echo "Purpose: " & objItem.Purpose
    WScript.Echo "QuotasDisabled: " & objItem.QuotasDisabled
    WScript.Echo "QuotasIncomplete: " & objItem.QuotasIncomplete
    WScript.Echo "QuotasRebuilding: " & objItem.QuotasRebuilding
    WScript.Echo "Size: " & objItem.Size
    WScript.Echo "Status: " & objItem.Status
    WScript.Echo "StatusInfo: " & objItem.StatusInfo
    WScript.Echo "SupportsDiskQuotas: " & objItem.SupportsDiskQuotas
    WScript.Echo "SupportsFileBasedCompression: " & objItem.SupportsFileBasedCompression
    WScript.Echo "SystemCreationClassName: " & objItem.SystemCreationClassName
    WScript.Echo "SystemName: " & objItem.SystemName
    WScript.Echo "VolumeDirty: " & objItem.VolumeDirty
    WScript.Echo "VolumeName: " & objItem.VolumeName
    WScript.Echo "VolumeSerialNumber: " & objItem.VolumeSerialNumber
Next

答案4

这是我前段时间编写的一个非常粗糙的 vbscript。

这实际上是 HTA 的一部分,它以 HTML 形式提供磁盘信息。我为您删除了所有 HTML,并添加了一些标签,使内容稍微对齐。

Const BYTES_TO_GB = 1073741824

strComputer  = "computer"
Wscript.Echo "Disk Usage - " & strComputer & vbCrLf
Wscript.Echo "Volume" & vbTab & vbTab & "Size" & vbTab & _
   "Free" & vbTab & "% Free" & vbCrLf

Set objWMIService = GetObject("winmgmts://" & strComputer)
Set colLogicalDisk = objWMIService.ExecQuery( _
    "SELECT DeviceID,VolumeName,Size,FreeSpace FROM Win32_LogicalDisk WHERE DriveType=3")

For Each objLogicalDisk In colLogicalDisk
  intTotalSize = objLogicalDisk.Size / BYTES_TO_GB
  intFreeSpace = objLogicalDisk.FreeSpace / BYTES_TO_GB
  Wscript.Echo objLogicalDisk.VolumeName & " (" & objLogicalDisk.DeviceID & ")" & _
    vbTab & FormatNumber(intTotalSize,0) & " GB" & _
    vbTab & FormatNumber(intFreeSpace,0) & " GB" & _
    vbTab & FormatNumber(intFreeSpace/intTotalSize*100,0) & " %"
Next

显然,您需要为 strComputer 填写一个值。如果您喜欢 GiB 而不是 GB,也可以调整常数。

希望这可以帮助。

相关内容