开发者

When accessing a logical drive's space status, the total drive results are correct, but the free space results are not

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, 开发者_StackOverflownot 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜