ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> activeperl
activeperl
RE: Problem with Win32::FileOp->Disconnect
by Ramkumar other posts by this author
Jun 18 2009 2:21AM messages near this date
RE: Problem with Win32::FileOp->Disconnect | RE: Installed 5.10, need to re-install packages? (sanket vaidya)
Hi,

We can also use dos command "net use" using system method to achieve your
below request.

Regards,
Ramkumar,

-----Original Message-----
From: activeperl-bounces@[...].com
[mailto:activeperl-bounces@[...].com] On Behalf Of Oeschey,
Lars (I/ET-83, extern)
Sent: Thursday, June 18, 2009 2:09 PM
To: activeperl@[...].com
Subject: Problem with Win32::FileOp-> Disconnect

Hi,

I'm writing a simple network copy script, but fail at disconnecting an
already connected drive. I got this so far:

----------------snip------------------------
use strict;
use warnings;
use Win32::FileOp;

my $user="xx";
my $password="xx";
my $path="\\\\deaudiis0957\\oeschela\$";
my $lettermatch=0;


print "Using User: $user\n";
print "Using Path: $path\n";
print "Checking mapped drives....\n";

my %mapped=Mapped;

while((my $key, my $value) = each(%mapped)) {
	print "$value\n";
	if (lc($value) eq lc($path)) {
		$lettermatch=1;
		print "..........Already Mapped!!.........\n";
	}
}

if ($lettermatch==1) {
	print "Disconnecting $path\n";
	Disconnect $path, {persistent=> 1,force=>1} or &ConnError;
}

sub ConnError{
	my $err=Win32::FormatMessage(Win32::GetLastError());
	print $err;
	print "Win32Error: $err\n";
	exit 1;
}

--------------snip--------------------

when I run it, it finds the mapped drive, but fails on disconnecting it:

Using User: deaudi00\oeschela
Using Path: \\deaudiis0957\oeschela$
Checking mapped drives....

\\DEAUDIIS0957\Oeschela$
..........Already Mapped!!.........
Disconnecting \\deaudiis0957\oeschela$
Diese Netzwerkverbindung ist nicht vorhanden.
Win32Error: Diese Netzwerkverbindung ist nicht vorhanden.

(translated it says "This network connection doesn't exist")
Any ideas what goes wrong here?

Lars
_______________________________________________
ActivePerl mailing list
ActivePerl@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_______________________________________________
ActivePerl mailing list
ActivePerl@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Lars Oeschey
Jenda Krynicky
Lars Oeschey
Ramkumar

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved