Did a search of old messages and found this one. I pasted it in a file as is and ran it from my computer and worked fine. A possible starting point for you.
Wags ;) ============================================================================ ================== ----- Original Message ----- From: "Francoys Crepeau" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, April 01, 2002 9:37 AM Subject: How to find disk stats for a drive letter? > I'm using ActiveState Perl 5.6 on NT4 or Win2K, and I'm trying to figure > out how to calculate the disk stats (i.e.: disk space used, disk space > left, etc.) for a given drive letter. > > Does anyone here know of a straightforward way of doing this? > > Thanks! > Here's a demo that someone ($Bill ?) posted to this list some time back: #code starts on next line use strict; use Win32::API; my $v = 1; # set to 1 for verbose sub DRIVE_UNKNOWN { 0; } # The drive type cannot be determined. sub DRIVE_NO_ROOT_DIR { 1; } # The root directory does not exist. sub DRIVE_REMOVABLE { 2; } # The drive can be removed from the drive. sub DRIVE_FIXED { 3; } # The disk cannot be removed from the drive. sub DRIVE_REMOTE { 4; } # The drive is a remote (network) drive. sub DRIVE_CDROM { 5; } # The drive is a CD-ROM drive. sub DRIVE_RAMDISK { 6; } # The drive is a RAM disk. my $GetDriveType = new Win32::API("kernel32", "GetDriveType", ['P'], 'N') or die Win32::FormatMessage(Win32::GetLastError()); my $GetDiskFreeSpace = new Win32::API("kernel32", "GetDiskFreeSpace", ['P','P','P','P','P'], 'N') or die Win32::FormatMessage(Win32::GetLastError()); foreach ('A'..'Z') { my $Drive = "$_:\\"; my $ret = $GetDriveType->Call($Drive) or die "GetDriveType: ", Win32::FormatMessage(Win32::GetLastError()); if ($ret == DRIVE_CDROM) { print "$_: CD-ROM\n" if $v; next; } elsif ($ret == DRIVE_UNKNOWN) { print "$_: Unknown\n" if $v; next; } elsif ($ret == DRIVE_NO_ROOT_DIR) { print "$_: No root dir\n" if $v; next; } elsif ($ret == DRIVE_REMOVABLE) { print "$_: Removeable\n" if $v; next; } $Drive = "$_:\\\0"; my $SecsPerCluster = pack ("I", 0); my $BytesPerSec = pack ("I", 0); my $FreeClusters = pack ("I", 0); my $TotClusters = pack ("I", 0); $ret = $GetDiskFreeSpace->Call($Drive, $SecsPerCluster, $BytesPerSec, $FreeClusters, $TotClusters) or print "GetDiskFreeSpace $_: ", Win32::FormatMessage(Win32::GetLastError()); my $SPC = unpack ("I", $SecsPerCluster); my $BPS = unpack ("I", $BytesPerSec); my $FC = unpack ("I", $FreeClusters); my $TC = unpack ("I", $TotClusters); if ($ret) { printf "%-2.2s %-9.3f MB Free\n", $Drive, $SPC * $BPS * $FC / (1024 * 1024); printf "\tSecsPerCluster = %u\n\tBytesPerSec = %u\n" . "\tFreeClusters = %u\n\tTotClusters = %u\n", $SPC, $BPS, $FC, $TC if $v; } else { print "Error getting drive info '$Drive'\n"; } } #^---- Code ends on line above I think that's about as "straight forward" as it gets :-) Cheers, Rob _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs -----Original Message----- From: Thomas Browner [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 12, 2002 11:59 To: [EMAIL PROTECTED] Subject: disk stats Is there away that I can get disk stats from a windows machine using perl? Thomas Browner ********************************************************** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. **************************************************************** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]