in reply to Using Win32 network shares
What do you not understand? The two things from his book worked for me. However, I did remove the $ from the RemoteName assignment.
use Win32::NetResource; use Win32::WinError; use strict; use warnings; my %NetResource = ( LocalName => "R:", RemoteName => "\\\\Public\\Depot" ); print $NetResource{RemoteName}; my $User = ""; my $Password = ""; if ( Win32::NetResource::AddConnection( \%NetResource, $Password, $Use +r, 1) ) { print "Successful!\n"; } else { print NetError(); } sub NetError { my ( $Error, $Text, $Provider, $Result); $Error = Win32::GetLastError(); if( ERROR_EXTENDED_ERROR == $Error ) { Win32::NeResource::WNetGetLastError( $Error, $Text, $Provider +); $Result = "Error $Error: $Text (generated by $Provider)"; } else { $Text = Win32::FormatMessage( $Error ); $Result = "Error $Error: $Text"; } return $Result; }
Keep in mind if the user and password are blank that says to keep it local to the machine you are accessing. If you are accessing a wide open share then you will have no problems. Otherwise, it wants an id and password which is bad since the password is plaintext. But if you are the sole user of the script and people won't see it....
And don't forget that if you use this to disconnect and or allow for finding the share already mounted.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
The Solution Re: Using Win32 network shares
by John M. Dlugosz (Monsignor) on Apr 15, 2002 at 19:36 UTC | |
|
Re: Re: Using Win32 network shares
by John M. Dlugosz (Monsignor) on Apr 05, 2002 at 19:49 UTC | |
by Marza (Vicar) on Apr 06, 2002 at 00:46 UTC |