Enumerate mapped drives using WMI (Perl)
This code can be found in
Chapter 7 of Windows XP Cookbook
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the Perl code from this site.
# From the book, "Windows XP Cookbook"
# ISBN: 0596007256
use Win32::OLE qw(in);
$strComputer = '.';
$objWMI = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2');
$colDrives = $objWMI->ExecQuery('select * from Win32_MappedLogicalDisk');
print "Mapped Drives:\n";
foreach my $objDrive (in $colDrives) {
print ' Device ID: ' . $objDrive->DeviceID, "\n";
print ' Volume Name: ' . $objDrive->VolumeName, "\n";
print ' Session ID: ' . $objDrive->SessionID, "\n";
print ' Size: ' . $objDrive->Size, "\n";
print "\n";
}
|
This code has been viewed 1135 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|