Creating a login script can be an easy way to solve network issues without active directory in a small network.  There are several common commands we have used over the years which help us map drives, add printers, copy files and folders, and more.  This page is a great guide made up from years of practice on different servers with different objectives.  We will add to it with more commands in the future.

First to know how to make a login script.  You have to make a notepad file and name it something like “login.bat”.  The easiest way to assign it to a user is to put the login.bat file in the “NETLOGON” part of the server share.  To find your NETLOGON folder, open the finder and navigate to your server.  You can do it either by IP address or by server name.  So // or //server would show you the network shares.  Make a text file there or make one in a spare drive and copy it there.  Remember, it has to be a .bat file.

Once you make the file, you can paste a few commands, here are some of our favorites:

@echo off – Turns off the command prompt when run.  It doesn’t give any feedback it is running.  Sometimes a big black command box popping up can confuse users.

net use * /delete /y – This deletes all existing drives, we do this to remove all existing drives if we are mapping new drives on a network, or if we add new information and change drive letters.  I leave this here as the Net Use command below will re-map the drives.

Net Use command:

net use S: \\server\Share Persistent:Yes – I always have one shared drive, typically I share this drive from the D or data drive of the server.  It will be shared with all network users.

net use L: \\server\Financial Persistent:Yes – There is normally a financial drive only shared with administrators of the business, make special permissions on the share to not share with all users, but only the people or group who needs access

net use k: \\server\Drake Persistent:Yes – Special software shares are typically shared with a domain user share setting to let any users of the domain access the software.  Never use the “Everyone” share as you don’t need a login to see it.

net use z: \\server\Scans Persistent:Yes – I always map a network scans folder.  Sometimes, there are usernames in the shared folder only the user can see.
net use P: \\server\Users\%username% Persistent:Yes – This will map a personal folder for the user to have their own stuff.
net use t: \\server\toolbox Persistent:Yes – For network administrators only, we share this with all computers so we have the software to do our jobs
net use q: “\\server\QB Data” Persistent:Yes – This can be shared with administrators, but in this case, we had a financial firm who used QB files for other businesses so we separated them.

xcopy t:\shortcuts\*.* “c:\Users\%username%\desktop” /D /E /C /R /I /K /Y  – We make a folder in the Toolbox or T drive named shortcuts.  This little gem copies anything in that folder to your user’s network desktop folder.  Quite nifty.  The extra letters at the end make sure it copies everything.

rem start \\\sharp – The REM command is a command that “Comments” out information, or makes it where the script will not run that command, but it is not deleted.  Great for keeping something around which may be used later.

start \\\xerox – The start command is great for mapping network printers.  First, you install a printer on the server, then you share the printer and name it, in this case the printer share is xerox.  Then you put this little piece of code in it, and it will install the printer on all computers with the login script.

We hope this helps, we’ve gone through many other forums and years of experience to put this together.  Happy coding!

Here is the script without the info:

@echo off

net use * /delete /y

net use S: \\server\Share
net use L: \\server\Financial
net use k: \\server\Drake
net use z: \\server\Scans
net use P: \\server\Users\%username% Persistent:Yes
net use t: \\server\toolbox
net use q: “\\server\QB Data” Persistent:Yes

xcopy t:\shortcuts\*.* “c:\Users\%username%\desktop” /D /E /C /R /I /K /Y

rem start \\\sharp

rem start \\\xerox