Solved

Can Total Size and Free Space of Local Disks be obtained from window registry?

Posted on 2011-03-07
4
323 Views
Last Modified: 2012-05-11
Would like to get the Total Size and Free Space of Local Disk like C:\ or D:\. The info must be saved in window registry. How to retrieve the info??
0
Comment
Question by:jl66
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Assisted Solution

by:grossac
grossac earned 200 total points
ID: 35060809
You can use WMI to query the data and calculate free space.

Use the Win32_LogicalDisk class and the FreeSpace property.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk")
For Each objDisk in colDisks
    Wscript.Echo "DeviceID: " & objDisk.DeviceID      
    Wscript.Echo "Free Disk Space: " _
        & objDisk.FreeSpace
Next


AND

 Use the Win32_LogicalDisk class, and the Size property.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk")
For Each objDisk in colDisks
    Wscript.Echo "DeviceID: " & objDisk.DeviceID      
    Wscript.Echo "Disk Size: " & objDisk.Size
Next


Here's a link to several other items you can get...
http://msdn.microsoft.com/en-us/library/aa394592(v=vs.85).aspx
0
 
LVL 19

Accepted Solution

by:
Thommy earned 300 total points
ID: 35060970
You cannot find such information in the registry.

Use this script to retrieve disk and drive infoirmation...
http://www.pcreview.co.uk/forums/finding-hard-disk-information-registry-t3711144.html

diskinfo.vbs
0
 
LVL 19

Assisted Solution

by:Thommy
Thommy earned 300 total points
ID: 35061065
You can also use WinApi-function GetDiskFreeSpace to retrieve info about a specified disk...

GetDiskFreeSpace Function
http://msdn.microsoft.com/en-us/library/aa364935(v=vs.85).aspx

You can call API functions from nearly all programming languages (e. g. Delphi, Visual Basic, C...)
0
 

Author Closing Comment

by:jl66
ID: 35065938
Thanks both. I thought the local drive info must be saved in registry in local computer.Perhaps not.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question