Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Checking status of Network Mapped Drives

by AltBlue (Chaplain)
on Aug 04, 2008 at 10:59 UTC ( [id://702025]=note: print w/replies, xml ) Need Help??

in reply to Checking status of Network Mapped Drives

If all you really want it's to *check* the connection status, I'd avoid using such an approach because it's slow and auto-vivifying (Windows tries to activate each connection you want to read from).

IMHO a better way would be to query the Windows Management Instrumentation (WMI) infrastructure through DBD::WMI:

use strict; use warnings; use DBI; my $dbh = DBI->connect('dbi:WMI:'); my $sth = $dbh->prepare(<<'WQL'); SELECT * FROM Win32_NetworkConnection WHERE ConnectionState != 'Connected' WQL $sth->execute() or die $dbh->errstr; while (my ($con) = $sth->fetchrow_array) { printf "%s\t%s\n", $con->ConnectionState, $con->Name; }

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://702025]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (2)
As of 2024-06-15 12:00 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.