"Thomas R Wyant_III" <[EMAIL PROTECTED]> writes:
> Have you read the docs that come with ActivePerl? You might want to
> check out Win32::NetResource.
I had not noticed that one; thanks.
You can also use WSH for this. A sample "map-drive.pl" script is
below.
- Pat
use warnings;
use strict;
use Win32::OLE;
sub die_usage () {
die "Usage: $0 <drive> <share>\n";
}
scalar @ARGV == 2
or die_usage ();
my ($drive, $share) = @ARGV;
$drive =~ /^[a-z]:$/i
or die_usage ();
# Bomb out completely if COM engine encounters any trouble.
Win32::OLE->Option ('Warn' => 3);
# Get WshNetwork object. See
# <http://msdn.microsoft.com/library/en-us/script56/html/wsobjwshnetwork.asp>
my $wsh_network = Win32::OLE->CreateObject ('WScript.Network');
# Remove network drive forcibly, if it is already mapped. See
# <http://msdn.microsoft.com/library/en-us/script56/html/wsmthremovenetworkdrive.asp>
-e "$drive/"
and $wsh_network->RemoveNetworkDrive ($drive, 1);
# Map network drive. See
# <http://msdn.microsoft.com/library/en-us/script56/html/wsmthmapnetworkdrive.asp>
$wsh_network->MapNetworkDrive ($drive, $share);