kevinliu23 said:
Just tried your solution Tim, worked like a charm.
It's great because I don't even have to worry about the computer name.
A question regarding the rootPath parameter...how would I be passing
it? Would I be passing it as...
tuple = win32api.GetDiskFreeSpace(r'C:')
or just leave it blank and the function will automatically use the
rootPath of where the .py file resides?
Both have returned the correct result.
The simple answer is: I'm not sure. If you experiment and find
something which works, just use it!
Something which SickMonkey made me return to your question.
Are you trying to find the disk space available on a
different machine (possibly on several different machines)?
If so, then WMI is definitely your answer. You can
run -- from your machine -- one piece of code which
will attach to several different machines to give
you the answer. (as per Sick Monkey's later post).
If I've read too much into your question, well nothing's
ever wasted on the internet. Here's some sample code
which uses the wmi module from:
http://timgolden.me.uk/python/wmi.html
<code>
machines = ['mycomp', 'othercomp']
for machine in machines:
print "Machine:", machine
c = wmi.WMI (machine)
# only consider local fixed disks
for disk in c.Win32_LogicalDisk (DriveType=3):
print disk.Name, disk.FreeSpace
print
</code>
Yes, you could even write:
for disk in wmi.WMI (machine).Win32_LogicaDisk (DriveType=3):
but I'd find it a touch unwieldy. YMMV.
HTH
TJG