Enumerate all the remote drives

G

Gary Chan

I want to write a perl script that enumerates all the local drive names
that are connecting to remote drives in Windows. I think
Win32::NetResource is one of the possible module but I can't figure out
how to do this.

Can anyone help?

Gary
 
B

Bob Walton

Gary said:
I want to write a perl script that enumerates all the local drive names
that are connecting to remote drives in Windows. I think
Win32::NetResource is one of the possible module but I can't figure out
how to do this. ....
Gary

Win32::NetResource seems to have issues with removable-media drives with
no media loaded. You might try capturing and processing the output from
the DOS command "NET USE". Your mileage may vary depending upon your
version of Windoze. Something like:

for(`net use`){print "$1 $2\n" if /([A-Z]:)\s*(.*)/}

perhaps [tested on Windoze 98SE, AS Perl 806].
 
J

Jay Tilton

: I want to write a perl script that enumerates all the local drive names
: that are connecting to remote drives in Windows. I think
: Win32::NetResource is one of the possible module but I can't figure out
: how to do this.

#!perl
use warnings;
use strict;
use Win32::OLE 'in';

my $fso = Win32::OLE->new('Scripting.FileSystemObject');
for ( in $fso->Drives ) {
print "Drive $_->{DriveLetter} is a remote volume\n"
if $_->{DriveType} == 3;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,538
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top