http://qs321.pair.com?node_id=1106058


in reply to Re^2: Error with GetDRIVE() when using a mapped drive
in thread Error with GetDRIVE() when using a mapped drive

Hi, Here is the script
#!perl use warnings; use strict; use Win32::OLE; my $d = $fs->GetDrive('Y:') or die ; my $TotalSize = $d->{TotalSize}; my $FreeSpace = $d->{FreeSpace}; my $usedSpace = $d->{TotalSize} -= $d->{FreeSpace}; my $AvailableSpace = $d->{AvailableSpace} *=100; my $AvailUsed = $AvailableSpace /= $d->{TotalSize}; my $SpaceLeft = $d->{AvailableSpace} /= $AvailUsed; my $MappedDriveSpaceAvailable = $AvailUsed *= 100; print $MappedDriveSpaceAvailable;

I have been looking and I do not see any syntax errors. any suggestions?

Replies are listed 'Best First'.
Re^4: Error with GetDRIVE() when using a mapped drive
by Loops (Curate) on Nov 04, 2014 at 15:32 UTC

    Yes, you completely dropped the creation of the OLE filesystem object, thus $fs is left undefined. And you dropped the error message from the die statement.

    my $fs = Win32::OLE->CreateObject('Scripting.FileSystemObject'); my $d = $fs->GetDrive('Y:') or die "GetDrive failed $!";