Map a network drive (Perl)

This code can be found in Chapter 7 of Windows XP Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the Perl code from this site.

# From the book, "Windows XP Cookbook"
# ISBN: 0596007256

# ------ SCRIPT CONFIGURATION ------

use Win32::OLE;

$strDrive = '<Drive>';
# e.g. N:
$strPath = '<Path>';
# e.g. \\rtp01\c$\temp
$strUser = '<User>';
# e.g. AMER\rallen
$strPassword = '<Password>';
$boolPersistent = 1;
# True = Persistent ; False = Not Persistent
# ------ END CONFIGURATION ---------
$objNetwork = Win32::OLE->new('WScript.Network');
$objNetwork->MapNetworkDrive($strDrive, $strPath, $boolPersistent, $strUser, $strPassword);
print "Successfully mapped drive\n";

This code has been viewed 3177 times.

New from the creators of TechTasks.com: StatSheet.com