We are going to create a script to map network drives and printers for Active Directory users. This script will be run automatically at logon and will be written in Visual Basic.

Path to the domain controller where the script should live is:

%windir%\SYSVOL\%domainname%\Scripts

File name can be any, but file extension has to be .vbs. And its content will be as follows:

'Map network drives
Option Explicit
Dim objNetwork
Dim strDriveLetter, strRemotePath, strUserName
Set objNetwork =WScript.CreateObject("WScript.Network")
strDriveLetter = "U:"
strRemotePath = "\\server\Data"
strUserName = objNetwork.UserName
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath & "\" & strUserName
strDriveLetter = "V:"
strRemotePath = "\\server\Data\Common"
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
'Map network printers
Dim strUNCPrinter
strUNCPrinter = "\\server\HPLJD1"
objNetwork.AddWindowsPrinterConnection strUNCPrinter
strUNCPrinter = "\\server\HPLJD2"
objNetwork,AddWindowsPrinterConnection strUNCPrinter
strUNCPrinter = "\\server\HPLJD3"
objNetwork,AddWindowsPrinterConnection strUNCPrinter
WScript.Quit

Obviously we need to have the adequate network resources referred by the script. Besides that, I’ve seen some SysAdmins that use .bat or .cmd scripts with the net use command. That depends on your style.