Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NT Logon scripts & groups

Status
Not open for further replies.

SunnyByfleet

Technical User
Feb 24, 2003
146
GB
Simple one this, brought on by my obvious premature senility.

I'm writing a standard login script for users logging on to an NT domain. If the user is a member of a certain group, I want a mapping to occur. I've done this loads of times before, but can't for the life of me remember the syntax. It was something like

IF %MEMBER_OF% "ACCOUNTS" NET USE J: \\BLAH\BLAHBLAH

Please help an old man before he pulls his remaining hair out.

Thanks
 
Remember that IFMEMBER needs to be in the same directory as the scripts
Example Login Script
@echo off

set DUMPFILE=c:\mtplogon.dmp
set GLOBALDRIVE=p:
set GLOBALSHARE=\\sys\directory1
set group1=Accounts

if %OS% == Windows_NT goto winnt >nul

:win

echo Syntax Error is expected if running Windows 3.11, 95 or 98

cls

echo.

echo Welcome to the My Domain. Please wait while your logon is processed...

echo.

echo Removing Previously Used Connections

echo.

if exist x: net use x: /delete >nul
if exist y: net use y: /delete >nul
if exist z: net use z: /delete >nul

echo.

echo Now Adding Network Drives

echo.

if not exist x: net use x: \\sysx\directory2
if not exist y: net use y: \\sysx\forms
if not exist z: net use z: \\sysx\home$

echo.

echo Setting Time with PDC

echo.

echo y | net time \\sysz /SET /Y

echo.

rem Special fix for Windows logon script end bugs
if exist c:\windows\*.* echo . >c:\windows\lmscript.$$$
if exist c:\win95\*.* echo . >c:\windows\lmscript.$$$

rem End of Logon Script
echo --- LOGON SCRIPT END $Revision: 2 $ ---
if not "%DUMPFILE%"=="" net use >%DUMPFILE%
if not "%DUMPFILE%"=="" set >>%DUMPFILE%

goto end

:winnt

echo.

echo Welcome to the MyDomain. Please wait while your logon is processed...

echo.

ifmember QuitLogon
if not errorlevel 1 goto NOGROUPS1
exit

:NOGROUPS1

echo.

echo Removing Previously Used Connections

echo.

if exist x: net use x: /delete >nul
if exist y: net use y: /delete >nul
if exist z: net use z: /delete >nul

echo.

echo Now Adding Network Drives

echo.

if not exist x: net use x: \\sysx\directory2 /persistent:no
if not exist y: net use y: \\sysx\forms /persistent:no
if not exist z: net use z: \\sysx\%username%$ /persistent:no


echo.

rem MAPPING Accounts USERS TO GLOBAL DRIVE
rem WIN9X CLIENTS HAVE TO PASS ON THIS SECTION
if "%GLOBALDRIVE%"=="" goto NOGROUPS
if exist %GLOBALDRIVE%*.* net use %GLOBALDRIVE% /delete
ifmember %GROUP1%
if not errorlevel 1 goto NOGROUPS
echo --- Mapping %GLOBALDRIVE% to %GLOBALSHARE%
net use %GLOBALDRIVE% %GLOBALSHARE% /persistent:no

:NOGROUPS



echo.
echo
set GLOBALDRIVE2=l:
set GLOBALSHARE2=\\sysy\dir3
set group2=Data

echo ....Mapping APL

if "%GLOBALDRIVE2%"=="" goto NOGROUPS2
if exist %GLOBALDRIVE2%*.* net use %GLOBALDRIVE2% /delete
ifmember %GROUP2%
if not errorlevel 1 goto NOGROUPS2
echo --- Mapping %GLOBALDRIVE2% to %GLOBALSHARE2%
net use %GLOBALDRIVE2% %GLOBALSHARE2% /persistent:no
:NOGOURPS2

echo Now Synchronizing Local Time With The Server

echo.

net time \\sysz /set /y

goto end

:end

 
Excellent. Just the ticket. I downloaded IFMEMBER from Microsoft and now I'm smokin'.

It wasn't the way I used to do it though, but it works very well indeed. Thanks once again.
 
you could try it this way.
eg if you just want admins to get a set of drives create a login script called admindrives.bat. then use the net use command in that script, then for standard drive maps create one called stddrives for example.
then create a login script called logon.bat, add call lines which call all the login scripts you have just created, then add this login script to all your users. then create groups for all the diffrent scrips you have just made, ed a group called admin drives for users who you want to get the admin drives etc. then heres the clever bit set the file permissions on the login drives so that only the group who you want to run it can read and exceute it.
now just add users you want to the groups which have access to the login scripts.

eg if paul needed admin drives then paul would be a member of the admin drives group

then if Jo needed the standard drives add her to the standard drivers group, jo's login script would try to run to admin drives script but would get an access denied so wouldnt get the mappings.

HTH

Marc Marc Turner
Network Manager

E-Mail: Mturner@turnerm3.fsnet.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top