[524] in winnt

home help back first fref pref prev next nref lref last post

Login Script Example

daemon@ATHENA.MIT.EDU (Bryant C. Vernon)
Wed Aug 9 14:58:44 2000

Message-ID: <3991AAA9.BD90C0AB@mit.edu>
Date: Wed, 09 Aug 2000 15:02:02 -0400
From: "Bryant C. Vernon" <bcvernon@MIT.EDU>
Reply-To: bcvernon@MIT.EDU
MIME-Version: 1.0
To: ntpartners@mit.edu
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi All,

I finally am getting around to sending this out.  Enjoy!

Bryant

**************
1st login script
**************

The purpose of the first login script is to start the actual login
script in a minimized window.  We do this so that users do not have to
stare at a blnak black windown while the login script executes.
----------------------------------------------------------------------------------

@ECHO OFF
REM Make sure that users don't see "junk" by setting echo off
start "Login Script" /min /high \\dlp-pdc\netlogon\login-2nd.cmd
REM Use the start command to start the login script minimized (/min)
with
REM the title "Login Script" and make it high priority (/high)
EXIT
REM Exit this dos prompt

**************
2nd Login Script
**************

The purpose of this script is to customize the user's environment in a
few different ways.  First, we map various drives that the user needs.
Secondly, we ensure that the user's account is set up properly.  Lastly,
we notify the user of any information we think they should
know--warning, etc.


REM Set all the variables we will use in the script--this makes script
wide changes
REM easier to make--you only have to make them in one place (for
example, if you
REM need to use the same script for several different
domains/departments).
REM set userdirectory=users
set userserver=dlp-pdc
REM The name of the server that contains users' home directories and
profiles.
set appserver=dlp-pdc
REM The name of the application server--in this case it is the same as
the user server.
if exist "C:\winnt\win2000.txt" set OpSys=2000
REM Okay, this is ingenuity...in its most basic form.  Because there is
no easy way to determine the operating
REM system of the client's machine, I have created a text file on each
machine running windows 2000 (actually
REM I only created it on the master 2000 professional image) that
identifies that machine as a windows 2000
REM machine.  It is necessary to know the O/S as some things that need
to be done by the script must be done
REM in different ways depending on the client O/S.  Of course, I made
the file read only by everyone--best to
REM do so that it is not inadverdently deleted.  So, what the script
does is check to see if that text file exists,
REM and if it does it sets the variable opsys to 2000.

REM Map the software share
REM Notice that I am using the same technique as I did above  to
determine whether the s: drive has been
REM mapped properly.  I have created a file called
software-share-verification.txt in the share that is supposed
REM to be mapped to the s: drive.
if NOT exist s:\binn\software-share-verification.txt net use s: /delete
> NUL
REM If the file does not exist then the s: drive is not mapped properly
(or is not mapped at all)
if NOT exist s: net use s: \\%appserver%\software /yes > NUL
REM If the s: drive does not exist, then map it to the proper share.
if NOT exist s:\binn\software-share-verification.txt ECHO %USERNAME% on
%COMPUTERNAME% could not successfully map the s: drive to
\\%appserver%\software. >>
\\%appserver%\software\binn\data\logs\software-map.log
REM Finally, if the file does not exist, then there has been an error
mapping the s: drive to the correct share, so
REM note that in a log file.

REM Map the team share
if not exist t: net use t: \\%appserver%\shared /yes
REM  The team share is not crucial, so we do not as yet perform any
tests to ensure that it is mapped
REM properly

if exist z: (GOTO DELZ) ELSE (GOTO CHECKDIR)
REM The z: drive is the home drive in this contract.  The drive is
mapped to the users home directory differently,
REM depending on the O/S of the client machine.  To ensure that the z:
drive is mapped correctly, we
REM delete any mappings to the z drive if it happens to exist.

:DELZ
REM Check to see whether the user's home directory was set up
improperly.
if exist z:\net.txt echo %USERNAME% is incorrectly net used to the users
directory >> \\%appserver%\software\binn\data\netlog.log
if exist z:\net.txt net use z: /Delete > NUL
REM Once again you see the use of an if exist statement to check to see
whether a file I purposefully created
REM as an identifier exists.  In this case I am checking to see whether
the z: drive was mapped the old fashioned
REM NT way--i.e. to the users share.  I created a file in the users
share called net.txt.  If the z: drive was mapped
REM incorrectly, then we log it to a log file so that I can check to
make sure the users account was set up
REM properly (i.e. this error usually occurs when someone specifies a
home directory via the user profile
REM as apposed to letting the script do it itself.
REM If the user is on a windows 2000 machine, then the z: drive is net
used.
REM Use the net use command to get rid of the drive mapping.  If the
user is on
REM a Windows NT computer, unsubst the z: drive.
if "%OPSYS%"=="2000" (net use z: /d) ELSE (subst z: /D > nul)
REM If the Z: drive still exists, then log it as an error to the
netlog.log log file.
if exist z: echo %USERNAME% on %COMPUTERNAME% could not disconnect z: >>
\\%appserver%\software\binn\data\netlog.log

:CHECKDIR
REM Check to make sure that the users home directory is a valid UNC path
(i.e. that it does exist).
if exist \\%USERSERVER%\%userdirectory%\%USERNAME% goto mapuser
REM If it does exist then map the user's directory--if not, then assume
that this person's account has
REM not been set up properly.
goto setup

:mapuser
REM Depending on the  O/S we map the z: drive using different commands.
Windows 2000 no longer supports
REM mapping network paths with the subst command.  You are required to
use the net use command (which
REM now maps subfolders of shares).  The windows NT net use command,
however, cannot map subfolders of user shares, so you are required to
use the subst command, which can do that.
if "%OPSYS%"=="2000" (net use z:
\\%USERSERVER%\%userdirectory%\%USERNAME%) ELSE (subst z:
\\%USERSERVER%\%userdirectory%\%USERNAME%)
if exist z: ECHO %USERNAME% on %COMPUTERNAME% successfully mapped the z:
drive to \\%USERSERVER%\%userdirectory%\%USERNAME% >>
\\%APPSERVER%\software\binn\data\login-maps.log
goto common



:setup
REM Until I add the logic here, we are assuming the network is available
and that this user is new.
net send %USERNAME% We are now creating your home directory.
mkdir \\%USERSERVER%\%userdirectory%\%USERNAME%
mkdir \\%USERSERVER%\%userdirectory%\%USERNAME%\profile
mkdir \\%USERSERVER%\%userdirectory%\%USERNAME%\settings
mkdir \\%USERSERVER%\%userdirectory%\%USERNAME%\settings\Personal
if "%OPSYS%"=="2000" (net use z:
\\%USERSERVER%\%userdirectory%\%USERNAME%) ELSE (subst z:
\\%USERSERVER%\%userdirectory%\%USERNAME%)
goto common

:common
if exist z:\settings\eudora\owner.lok del z:\settings\eudora\owner.lok
REM Delete the owner.lok file if it exists.

start /min \\%appserver%\software\binn\current-user-all.exe
REM This is a registry update specific to this contract.
goto netscape

REM The following code ensures that the settings and folders that should
exist in the users' home directory
REM actually do.  If they don't exist, then the script creates them and
copies over any default settings.
:netscape
if exist z:\settings\netscape goto eudora
Echo --- Initializing your Netscape Settings ---
mkdir z:\settings\netscape
xcopy \\%appserver%\software\defaults\netscape\*.* z:\settings\netscape\
/s /e >NUL
goto eudora

:eudora
if exist z:\settings\eudora goto zephyrNT
Echo --- Initializing your Eudora Settings ---
mkdir z:\settings\eudora
xcopy \\%appserver%\software\defaults\eudora\*.* z:\settings\eudora\ /s
/e >NUL
net user %username% >
\\%appserver%\%userdirectory%\%USERNAME%\settings\Personal\user-info.txt

\\%appserver%\software\binn\perl.exe
\\%appserver%\software\binn\eudora-set.pl %userserver% %userdirectory%
%username% %fullname%
goto zephyrNT

:zephyrNT
if exist z:\settings\zephyrNT goto end
ECHO --- Initializing your zephyrNT Settings ---
mkdir z:\settings\zephyrNT
xcopy \\%appserver%\software\defaults\zephyrNT\*.* z:\settings\zephyrNT\
/s /e >NUL
goto files

:files
if exist z:\files goto end
ECHO --- Creating your files folder ---
mkdir z:\files
goto exit

:exit

REM A warning that we send to users when they log on informing that they
should save their files in the z:\files
REM directory.

:end
net send %USERNAME% Please note that it is necessary to save ALL your
files in Z:\files. We have set up the server to work this way and thus
will not be responsible for files that you save elsewhere, particularly
for files that you save on the desktop. Due to a peculiarity of Windows,
there is a fairly decent chance that any files stored on the desktop
will be irretrievably deleted.

EXIT


home help back first fref pref prev next nref lref last post