Solved

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

Posted on 2011-03-07
4
314 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks both. I thought the local drive info must be saved in registry in local computer.Perhaps not.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now