Hello All,
I'm working on what was supposed to be a simple little script to allow users on WinXP systems to remap drives to some DFS shares without having to logoff/on to the systems (classroom environment). When I run the app, I can get to the drives contents from the CMD prompt, but Windows Explorer does not display all of the drives. I'm trying it on 2 drives and it will show one or the other, sometimes neither, but never both. Closing and re-opening explorer does not make a difference and I cannot get to the drives by doing Start -> Run -> <driveletter>. If I kill and restart the explorer service (via task manager or on the command line) the drives will appear when explorer restarts. For a variety of reasons, I don’t want to restart explorer in support of this little script. Here’s some of the code (the share names have been changed to protect the innocent)...
my(%drvarray) = ( "X:","\\\\mydomain.com\\dfs\\pathto\\firstshare", "Y:","\\\\mydomain.com\\dfs\\pathto\\secondshare" ); #-- Do the work eval { $ncref = {}; $ncref->{'Scope'} = RESOURCE_GLOBALNET; $ncref->{'Type'} = RESOURCETYPE_DISK; $ncref->{'DisplayType'} = RESOURCEDISPLAYTYPE_SHARE; $ncref->{'Usage'} = RESOURCEUSAGE_CONNECTABLE; #-- Disconnect the drives first #-- Cannot connect dfs drives under different usernames foreach $letter (keys %drvarray) { Win32::NetResource::CancelConnection($letter,0,1); } #-- Now connect them again using the credentials foreach $letter (keys %drvarray) { $ncref->{'LocalName'} = $letter; $ncref->{'RemoteName'} = $drvarray{$letter}; if(!Win32::NetResource::AddConnection($ncref,$password,$username,0)) { Win32::NetResource::GetError($err); die Win32::FormatMessage($err); } } };
I'm using ActivePerl v5.6.1 Build 631/633 and the subroutine is being called from a TK form the simply prompts the user for their username and password. Anyone seen this before? Is there anyway to force Windows Explorer to re-query for drives like it does when it’s restarted? I was going to try and use Win32::FileOp but it does not appear to be bundled with this distribution of Perl and with this script potentially going out on hundreds of clients, I don’t want to require the installation of a specific module if at all possible.
Thanks in advance. Thanks,
|
XP explorer and AddConnection
Grakowsky, Richard \(ETS: Communications and Network Services\) Thu, 13 Feb 2003 06:00:07 -0800