How to check for remaining hard drive space in Windows?

Sick Monkey sickcodemonkey at gmail.com
Wed Feb 28 16:01:41 EST 2007


Sorry, I forgot to make a change.  You will need to change "COMPUTER_NAME"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 >>> from win32com.client import GetObject
>>> wmiObj = GetObject("winmgmts:\\\\COMPUTER_NAME\\root\\cimv2")
>>> diskinfo = wmiObj.ExecQuery("Select * from Win32_LogicalDisk")
>>> for disk in diskinfo:
...    print disk.Name, disk.FreeSpace


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/5d8d7bb9/attachment.html>


More information about the Python-list mailing list