ADVYON's Amazing Customer Service Portal!

How to make a simple login script for Windows Server 2008, 2008r2, 2012, 2016

Modified on: Fri, 31 Aug, 2018 at 4:19 PM

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 //192.168.1.100 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 jobsnet 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 \\192.168.1.100\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 \\192.168.1.100\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!

Sorry we couldn't be helpful. Help us improve this article with your feedback.

Related Articles

ABOUT THE ADVYON NAME

The name ADVYON was concieved from combining the words Advice and Beyond. When ADVYON was first conceptualized, it was to be a non profit company whose mission was to help other non profit companies with technology needs. Today, we have broadened our market to serve all. We still like to help others and have kept our core beliefs in helping our partners and community grow to build a better tomorrow.

ADVYON specializes in IT Support

Did you know that some of the best businesses in the world are right here in Charleston? We provide computer and network support to many amazing businesses right here at home. While helping all of these businesses, our philosophy stays the same, Always be Friendly, Competent, Competitive, and Passionate about what we do and who we help. We enjoy creating long lasting partnerships with our customers and share in the accomplishments for years.