in reply to Error with GetDRIVE() when using a mapped drive
I get a similiar error when checking my CD drive when there's no CD in it, perhaps you should check the drive's isReady property.
The below code works (for me) for fixed drives, available network shares, "ready" removable drives and gives "uninitialized" errors on "not-ready" removables - except for the DriveLetter, DriveType and isReady properties.
(BTW if called from the command line (I use DWIM perl), I get a "drive not ready" dialogue in the latter case. When called from Padre, the "uninitialized" comes directly)
Note that in must be imported explicitly.use warnings; use strict; use Win32::OLE 'in'; my $fs = Win32::OLE->CreateObject('Scripting.FileSystemObject'); for ( in $fs->Drives ) { print "$_->{DriveLetter}:\n"; my $d = $fs->GetDrive( $_->DriveLetter ); for ( qw(DriveLetter DriveType IsReady FileSystem TotalSize FreeSpac +e AvailableSpace) ) { print "$_: $d->{$_}\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Error with GetDRIVE() when using a mapped drive
by Corion (Patriarch) on Nov 04, 2014 at 08:39 UTC | |
by soonix (Chancellor) on Nov 04, 2014 at 08:43 UTC | |
by vanz (Initiate) on Nov 04, 2014 at 18:27 UTC | |
by soonix (Chancellor) on Nov 04, 2014 at 20:12 UTC | |
by vanz (Initiate) on Nov 04, 2014 at 21:45 UTC | |
|