Friday, February 25, 2011

Network Drive Mapping Scripts


If you are using network share drive, in which you to open drives again and again. To simplify that you can map the drives on your system, but if you have many network share drives and a large network, then you can use network drive mapping VbS scripts.
If you have single share drive then you can copy this code and paste in notepad, edit and save as it filename.vbs (filename which you want).
Set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "s:" , "\\servername\share folder"
If you are using more than one network share drive then you can copy and paste this script in notepad and save as it filename.vbs. In this script you can increase and decrease mapping drive, you can change drive latter in this script as you want J, K, L, M. put your server share folder unique path in “myserver\sale” according to sharing. If there will be any mistake it will not run, so edit it properly.
' Drive Map VBscript.vbs - Map Network Drive to J:,K:,L: and M:
' Example of VBScript Mapping Four drives in one script.
' ----------------------------------------------------'
Option Explicit
Dim objNetwork, strRemotePath1, strRemotePath2, strRemotePath3,
strRemotePath4
Dim strDriveLetter1, strDriveLetter2, strDriveLetter3, strDriveLetter4
strDriveLetter1 = "J:"
strDriveLetter2 = "K:"
strDriveLetter3 = "L:"
strDriveLetter4 = "M:"
strRemotePath1 = "\\myserver\sale"
strRemotePath2 = "\\myserver\it"
strRemotePath3 = "\\myserver\production"
strRemotePath4 = "\\myserver\marketing"
Set objNetwork = CreateObject("WScript.Network")
' Section which maps Four drives, J:,K:,L: and M:
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3
objNetwork.MapNetworkDrive strDriveLetter4, strRemotePath4
Wscript.Quit
' End of Windows Logon Script Example

3 comments:

Anonymous said...

How can this script be modifed to;

A) Remove existing mapped drive letters no longer needed?

B) Replace existing mapped drive letters with the new/updated path?

rakesh said...

thanks a lot ......u guys are teacher of whole world..

Anonymous said...

find login.bat under directory windows/sysvol/domain/scripts and type bellow

NET USE s: \\servername\foldershare
NET USE o: \\servername\%USERNAME%

Hit Counter