Category: Win32 Stuff
Author/Contact Info Andrew Crawford <>
Description: It's very easy to map a drive or a printer on your Windows workstation from Perl. This makes it very practical to write login scripts in Perl. I have not been able to find a pure-Perl method to check for the success of these operations. They always return success and no error variables are set.
use Win32::OLE;
my $workstation=Win32::OLE->CreateObject("WScript.Network");

# Add a printer
my $printerpath='\\\\server\\printername';

# Make it the default

# Map a network drive
my $drivepath='\\\\server\\sharename';
Replies are listed 'Best First'.
Re: Map drives and printers from Perl
by ikegami (Pope) on Jun 01, 2008 at 03:51 UTC

    my $printerpath="\\server\printername";
    should be
    my $printerpath="\\\\server\\printername";

    should be

    And it would be good if you showed how to check for success.