Wednesday, December 2, 2009

VBScript to map a network drive

You can also set this script to Scheduled Tasks run on User logon or System Startup.

' MNDUserName.vbs
' VBScript to map a network drive.
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.3 - April 24th 2005
' -----------------------------------------------------------------' 
Option Explicit
Dim objNetwork 
Dim strLocalDrive, strRemoteShare, strPer, strUsr, strPass
' Purpose of script to create a network object. (objNetwork)
' Then to apply the MapNetworkDrive method. Result J: drive
Set objNetwork = WScript.CreateObject("WScript.Network")

strLocalDrive = "L:"
strRemoteShare = "\\192.168.1.138\shared_folder_name"

strPer = "FALSE"

strUsr = "username"
strPass = "password"

objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, strPer, strUsr, strPass

Set objNetwork = Nothing

WScript.Quit

' End of MapNetworkDrive Example logon script.

No comments: