0

I am looking for a built-in Windows XP/Server 2003 utility that can pull drive information, similar to what the Disk Management mmc displays, including capacity and free space. Any ideas?

Diskpart doesn't seem to report free space and Disk Management doesn't seem to have an "export to text" feature. Any ideas?

Please note that I am not looking for any third-party tool recommendations. If it isn't a Windows built-in, I'll likely have to script it instead.

Kevin Kuphal
  • 9,134
  • 1
  • 35
  • 41
romandas
  • 3,302
  • 8
  • 39
  • 44

6 Answers6

3

For Windows XP and Server 2003, use the fsutil command

C:\Documents and Settings\administrator>fsutil volume diskfree C:
Total # of free bytes        : 14056869888
Total # of bytes             : 21459722240
Total # of avail free bytes  : 14056869888
Kevin Kuphal
  • 9,134
  • 1
  • 35
  • 41
2

DISKPART will show you this information at the volume level (for Windows Vista only)

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
Kevin Kuphal
  • 9,134
  • 1
  • 35
  • 41
  • I don't get the same level of detail that you do. Are you running this against a Basic or Dynamic disk? I only get the initial table; I don't get "Read-only" or anything below that. – romandas Jul 08 '09 at 19:22
  • My machine is a Windows Vista computer with Basic disks – Kevin Kuphal Jul 08 '09 at 19:24
  • The version is 6.0.6002. My Windows 2003 server has version 5.2.3790.3959 and it does not have this detail. – Kevin Kuphal Jul 08 '09 at 19:26
  • That must be it. On XP, the version I have is 5.1.3565 – romandas Jul 08 '09 at 19:29
  • It may be weird, but version 6.0.6002 is included in the Vista automated installation kit (http://www.microsoft.com/downloads/details.aspx?FamilyID=94BB6E34-D890-4932-81A5-5B50C657DE08&displaylang=en) and will work on Windows XP SP3 according to the Microsoft document for deploying XP on Netbooks. I don't know that I'd go through the trouble of downloading that huge kit just for this util, but if you're on XP SP3, just grab the file from a Vista machine. – Kevin Kuphal Jul 08 '09 at 19:35
  • Yeah, but does it have a remote query feature I can use from my admin workstation, or would I have to install that on all our XP and 2003 machines? – romandas Jul 08 '09 at 19:37
  • I don't believe that DISKPART works remotely. This option does not meet your "built in utility" criteria. See my other answer for a better solution – Kevin Kuphal Jul 08 '09 at 19:56
1

Every bit of information you could want regarding your logical disks:

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
Izzy
  • 8,224
  • 2
  • 31
  • 35
0

I'm not aware of any built-in option, I would just get all the info from WMI using VBScript or PowerShell.

ThatGraemeGuy
  • 15,473
  • 12
  • 53
  • 79
0

the technology you are looking for is WMI. For an overview on how to script for it see: WMI scripting primer.

WMI is the best way to handle remote systems managment. WMI can also be used with Powershell, but you are likley to see (for now) most examples in vbscript. Once you understand the concepts you can use the scriptomatic (vbscript) (powershell) to build your scripts

Jim B
  • 24,081
  • 4
  • 36
  • 60
0

Here's a very rough vbscript that I hacked together a while back.

This is actually part of an HTA that gives disk info in HTML. I stripped out all of the HTML for you and put in some tabs to make things line up a little.

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

Obviously, you'll need to fill in a value for strComputer. You can also adjust the constant if you like GiB instead of GB.

Hope this helps.

Anthony Lewis
  • 909
  • 7
  • 8