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
Solved

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

Posted on 2011-03-07
4
318 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
  • 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Event ID: 7023 / Source: Service Control Manager 4 145
Access denied running PowerPivot -SQL Server 2014 on Windows Server 2012 10 49
ticket bloat 3 50
Enterprise Mode 4 47
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…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

839 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