DISCLAIMER: I'm not an instructor, I haven't written any books, I don't
write code for a living, and there may be other ways to accomplish the same
thing as I have written. This is intended to help others so please keep
your opinions to yourself unless you have something constructive to add that
will benefit others. Additionally, this example script is intended for
tutorial purposes and will need 'tweaked' to suit your environment. I take
no responsibility for the use of this script in a production environment.
NOTES: There are tremendous amounts of information on the Internet and in
books on how to write scripts, what good practices are, and what variables
can be used in a login script (batch file). This should be enough to get
the average person going in short order. If anything is unclear, or if you
have questions, please post them. Remember, you will need to modify this
script for your server name, network share names, drive letters you require,
printer names, etc.
Okay, with BS out of the way, let's get going. First, you can find your
default login script by clicking Start - Run, type \\ServerName\netlogon,
click OK. This will open a folder with a batch file called
SBS_LOGIN_SCRIPT.bat. Using Notepad, WordPad, or your favorite text editor
open this file (note: you should be able to right-click the file and select
edit from the context menu). This file generally includes only one line
used for SBS client setups. Do not remove this line! It can be moved
around within the script, but leave it intact. If you don't already know
it, this line will tell you the name of your server.
Now, following will be a clean version of my sample login script followed by
a sample with notes. My notes will start with the "Note:" to help you
distinguish the difference. If this helps even one person, it was worth the
time. If you have further questions, please post them for all to learn
from.
Enjoy!
-TK
M/T Box Computers
<CLEAN LOGIN SCRIPT>
@echo off
rem ==================================================
rem
rem Title: Login Script
rem Author: Your Name
rem Date: Self-explanatory
rem Description: Network Login Script
rem
rem ==================================================
:SBS_SETUP
rem Default sbs2k3 client setup
\\ServerName\Clients\Setup\setup.exe /s ServerName
:MAPDRIVES
rem Connect network drives
if exist f:\*.* net use f: /d
net use f: \\ServerName\ShareName /persistent:no
if exist g:\*.* net use g: /d
net use g: \\ServerName\applications /persistent:no
if exist h:\*.* net use h: /d
net use h: \\ServerName\%username% /persistent:no
:PRINTERS
rem Connect network printers
net use lpt1: \\ServerName\Printer1ShareName /persistent:no
net use lpt2: \\ServerName\Printer2ShareName /persistent:no
:END
</CLEAN LOGIN SCRIPT>
<COMMENTED LOGIN SCRIPT>
Note: The word 'REM' is a way to add a remark to your batch file (login
script). It is a good idea to use remarks throughout your login script.
This will help later when troubleshooting why the login script is written
the way it is. You should also document dates of changes and why.
Note: The command 'ECHO' can be used to turn display on and off. 'ECHO'
followed by words will display those words on the screen. 'ECHO OFF' will
suppress all display until 'ECHO ON' is issued.
Note: The @ sign in front of 'ECHO OFF' says to not display this line also.
@echo off
rem ==================================================
rem
rem Title: Login Script
rem Author: Your Name
rem Date: Self-explanatory
rem Description: Network Login Script
rem
rem ==================================================
Note: The use of the colon ':' followed immediately by a word designates the
following lines as a section or routine within your script. This allows you
to move back and forth within the login script. This isn't normally
necessary, but I found it helpful to form good script writing habits early
on. A batch file will normally flow from top to bottom executing every line
it comes to that is not a remark line, and that is an actual command. You
can skip sections by using the 'GOTO' command. Often times I will check for
the existence of the drive mappings after they should have completed. If
they do not exist I will send the user to an error message section letting
them know something failed, with instructions to reboot and/or contact their
IT support. If you would like an example of this also, let me know and I
will post it.
:SBS_SETUP
rem Default sbs2k3 client setup
Note: Leave this line intact somewhere near the head of your script. As you
see here, this is the first actual line that executes in this script.
\\ServerName\Clients\Setup\setup.exe /s ServerName
:MAPDRIVES
rem Connect network drives
Note: Tests for and deletes drive mapping if it exists (ensures drive letter
isn't erroneously mapped elsewhere).
if exist f:\*.* net use f: /d
Note: Correctly maps drive letter to network share.
Note: Be sure to modify for your correct server name.
net use f: \\ServerName\ShareName /persistent:no
if exist g:\*.* net use g: /d
net use g: \\ServerName\applications /persistent:no
if exist h:\*.* net use h: /d
Note: I have used the variable 'UserName' below. The system will read this
as the login name of the user. If you setup a user share with each user's
login name, this line will correctly map a home drive for each user based on
their login name. Don't forget to set security and permissions on the user
shares you setup.
net use h: \\ServerName\%username% /persistent:no
:PRINTERS
rem Connect network printers
Note: This will map your network printers to LPT ports. This is normally
only necessary for older legacy (read: DOS) programs.
Note: Be sure to modify for your correct server name.
net use lpt1: \\ServerName\Printer1ShareName /persistent:no
net use lpt2: \\ServerName\Printer2ShareName /persistent:no
:END
</COMMENTED LOGIN SCRIPT>
--
Kevin Weilbacher [SBS-MVP]
"The days pass by so quickly now, the nights are seldom long"
"TK - M/T Box Computers" <te...@removethis.mtboxcomputers.com> wrote in
message news:emoxbsoo...@tk2msftngp13.phx.gbl...
-TK
M/T Box Computers
"Kevin Weilbacher [SBS-MVP]" <kweil...@gte.net> wrote in message
news:%23Pv2pcr...@TK2MSFTNGP12.phx.gbl...
"TK - M/T Box Computers" <te...@removethis.mtboxcomputers.com> wrote in
message news:emoxbsoo...@tk2msftngp13.phx.gbl...
You are most welcome!
-TK
M/T Box Computers