How to find out free disk space on a share via win32api?
Joe Francia
usenet at soraia.com
Mon May 5 16:00:47 EDT 2003
Lexy Zhitenev wrote:
> So, I have a share, say \\serv\shr1.
> I need to know how much free space I have on this share. Could anyone help
> me? I am running ActivePython 2.2.2 under Win2000.
>
> Regards, Lexy.
>
>
I'm not sure this will give you what you need, but you can use use WMI
calls if all machines are Win2k/WinXP:
## begin script ##
from win32com.client import GetObject
# use a dot (.) for local computer
wmiObj = GetObject("winmgmts:\\\\COMPUTERNAME\\root\\cimv2")
diskinfo = wmiObj.ExecQuery("Select * from Win32_LogicalDisk")
for disk in diskinfo:
print disk.Name, disk.FreeSpace
## end script ##
Example output:
A: None
C: 9364439040
D: 692006912
E: None
The WMI interface is pretty well detailed here, you just have to
translate everything from VBScript:
http://www.activxperts.com/activmonitor/windowsmanagement/wmi/samples/
You may need to combine several different calls to the WMI to get
exactly what you need based on your requirements.
Hope it helps,
jf
More information about the Python-list
mailing list