Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-25 12:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found