A batch file is a text file containing a series of commands intended to be executed by the command interpreter. When a batch file is run, the shell program reads the file and executes its commands, normally line-by-line.

The following script can be used as a logon script to map a network drive to users home directory  (or any directory) on the server or somewhere else.

1- Copy and past the script in a text editor, notepad will dose the job perfectly.
2- Make whatever change in need to suit your purposes. ie; change the server name and the  share name to reflect yours.

3- Save the file (any name you like) with extension of .bat, ie: logon.bat
4- You may test it on your local machine by double clicking it, you may assign it to a group or to just a single user within your windows network.

In this example i’ll map three network drives to a user, first one is the user network home drive, 2nd and 3rd are directory within user’s department and Public shard folder respectively.

Tip: If you want to assign the script to multi users to map their home directories you can use the variable %username%  instead of a single user’s account, This is true if the name of the home directory of a user is the same as his/her account’s username . ie:

instead of:

net use w: \\server\drives\user1 /PERSISTENT:YES

you may use:

net use w: \\server\drives\%username% /PERSISTENT:YES

And here comes the script:

:: BATCH FILE SCRIPT TO MAP NETWORK DRIVES FOR USERS AT LOGON
:: CREATED BY NATHAN JOSEPH http://nj180degree.net
:: APRIL 14th 2010
:: ISSUED UNDER THE GNU GPL (GNU GPL)
net use x: \\server\drives\user1 /PERSISTENT:YES
net use y: \\server\Departmentdata\Accounting /PERSISTENT:YES
net use z: \\server\public /PERSISTENT:YES

Share

Related posts:

  1. Simple Printer Logon Script – VBScripts