How to check for remaining hard drive space in Windows?

Sick Monkey sickcodemonkey at gmail.com
Wed Feb 28 15:59:34 EST 2007


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
>>>

On 28 Feb 2007 12:26:31 -0800, kevinliu23 at gmail.com <kevinliu23 at gmail.com>
wrote:
>
> HI,
>
> I am new to Python and wanted to know how to check for the remaining
> disk space on my Windows machine using Python? I was thinking of using
> the command line "dir" and trying to extract the output from there.
> But I'm not sure how to extract command line strings using Python
> either.
>
> Anyway help would be appreciated. :)
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070228/6da6b143/attachment.html>


More information about the Python-list mailing list