> i'm looking for a module for lists currently mapped drive,
> like NET USE but i don't want spawn a process.

here's an excerpt from a working program using Win32::FileOp:
(copy&paste won't run, it's not the full script)

---------------------------------------------------------
use warnings;
use Win32::FileOp;
use Win32;
use Win32::Shortcut;
use IO::Handle;

%mapped=Mapped;

while((my $key, $value) = each(%mapped)) {
        if ($debug) {print LOG "$value - $drive\n";}
        if (lc($value) eq lc($drive)) {
                $lettermatch=1;
                if ($debug) {print LOG "Mapped with letter\n";}
        }
}
if (-e "$ENV{USERPROFILE}\\Netzwerkumgebung\\Vobes Report.lnk") {
                $nolettermatch=1;
                if ($debug) {print LOG "mapped without letter\n";}
        }

if ($mode eq "connect") {
        if (!($lettermatch or $nolettermatch)) {
                Connect $drive,
{user=>$user,passwd=>$passwd,persistent=>0,force=>1} or &ConnError;
                $link=new Win32::Shortcut();
                $link->{"Path"}=$drive;
                $link->Save("$ENV{USERPROFILE}\\Netzwerkumgebung\\Vobes
Report.lnk");
        }
        if ($exec) {
                exec ("$drive" . "$exec") or print "couldn't exec $exec:
$!";
                if ($debug) {print LOG "exec error?: $!\n";}
        }
}

if ($mode eq "disconnect") {
        if ($nolettermatch) {
                unlink "$ENV{USERPROFILE}\\Netzwerkumgebung\\Vobes
Report.lnk" or print "couldn't remove link\n";
                Disconnect $drive, {persistent=>1,force=>1} or &ConnError;
        }
}
exit 0;

sub ConnError{
        $err=Win32::FormatMessage(Win32::GetLastError());
        print $err;
        if ($debug) {print LOG "Win32Error: $err\n";}
        exit 1;
}
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to