Re: How to check for remaining hard drive space in Windows?



Thanks so much for the help guys. I got the code Sick Monkey provided
to work on my computer. Now I"m more confused than ever though. :) I
thought the only standard modules provided by Python are listed here:

http://docs.python.org/modindex.html

But it appears that there are other modules available to me without
having to download third party code. Could someone point me to the
documentation of these other modules such as win32com.client? Thanks
everyone for your help. :)

Also, how could I get the computer name? I would be running this code
on another machine and don't want to change the computer name in the
code every time I port it to another computer. Thanks!

Kevin

On Feb 28, 4:16 pm, Tim Golden <m...@xxxxxxxxxxxxxxx> wrote:
[... re getting free disk space ...]

Sick Monkey wrote:
Here you are:

>>> from win32com.client import GetObject
wmiObj = GetObject("winmgmts:\\\\MGW01641\\root\\cimv2")
diskinfo = wmiObj.ExecQuery("Select * from Win32_LogicalDisk")
for disk in diskinfo:
... print disk.Name, disk.FreeSpace
...
A: None
C: 16978259968
D: None

Well it's not often someone beats me to a WMI
solution :) Just to be different, you can also
look at the GetDiskFreeSpace function in the
win32api module of the pywin32 extensions.

The doc says: """
tuple = GetDiskFreeSpace(rootPath)

Retrieves information about the specified disk, including the amount of
free space available.

Parameters

rootPath : string

Specifies the root directory of the disk to return information about. If
rootPath is None, the method uses the root of the current directory.

Win32 API References

Search for GetDiskFreeSpace at msdn, google or google groups.

Return Value
The return value is a tuple of 4 integers, containing the number of
sectors per cluster, the number of bytes per sector, the total number of
free clusters on the disk and the total number of clusters on the disk.
If the function fails, an error is returned.
"""

TJG


.



Relevant Pages

  • Re: bad clusters != bad sectors? CHKDSK. How many is normal?
    ... I know nothing about bad sectors but I know how to search with google ... >>From the beginning, WinXP has always needed to do CHKDSK, every 2 weeks ... and it often finds bad clusters and errors in the MFT. ... >A disk check has been scheduled. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Chkdsk problem...
    ... 1", which seems high to me since there's only 29,304,934 clusters on the disk. ... Sectors arent clusters. ... All that means is that the bad sectors arent being used in normal ops. ...
    (comp.sys.ibm.pc.hardware.storage)
  • Re: How to check for remaining hard drive space in Windows?
    ... re getting free disk space ...] ... The return value is a tuple of 4 integers, containing the number of sectors per cluster, the number of bytes per sector, the total number of free clusters on the disk and the total number of clusters on the disk. ...
    (comp.lang.python)
  • Win98 IO.SYS / JO.SYS
    ... Does anyone happen to know how many sectors or clusters are loaded of IO.SYS ... , under Win98? ... else off of the disk... ...
    (alt.lang.asm)
  • Win98 IO.SYS / JO.SYS
    ... Does anyone happen to know how many sectors or clusters are loaded of IO.SYS ... , under Win98? ... else off of the disk... ...
    (comp.lang.asm.x86)