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"; } }
In reply to Re: Error with GetDRIVE() when using a mapped drive
by soonix
in thread Error with GetDRIVE() when using a mapped drive
by vanz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |