tags:

views:

19

answers:

1

The problem appears to be with the The Win32_LogicalDisk class' free space property as it is showing only what the currently logged in user has rights to, not what free space actually exists.

Example code, though not entirely necc:

Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='Z:'")

' server share, total disk size, total disk free, percent free
tmpStatus = tmpStatus & arrShares(i) & "," & FormatNumber((objLogicalDisk.size / GBCONVERSION),,-1) & "," & _
FormatNumber((objLogicalDisk.FreeSpace / GBCONVERSION),,-1) & "," & _
((objLogicalDisk.FreeSpace / GBCONVERSION) / (objLogicalDisk.size / GBCONVERSION) * 100) & "@"

NOTE: This is for a virtual server network share, so the drive type is 4

Is there a better way? Again, the total drive space is correct, but the free space is not since from what I've found on MSDN it uses the current user's rights to determine free space. There must be another/better way.

A: 

Ok so the trick seems to be to use the file system object disk properties instead of the w32_logicaldisk properties. Using FSO, all of the numbers are accurate.

unrealtrip