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)
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";
}
}
Note that in must be imported explicitly.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|