Assigning different login scripts to users based upon their location can become a management nightmare. Instead of having multiple login scripts, you can create a single login script that checks the Subnet that the user is on
Requires Free Membership to View
Below is a simple batch file that determines the Subnet and maps a drive based on the Subnet.
@echo off cls REM LOGIN.BAT REM Default Login Script REM REM NOTE: When calling other batch files from this login script, there are two important things to keep in mind. REM - always be sure to use 'call' before the batch file name REM - never use 'exit' in the batch file that you are calling REM Failure to keep these things in mind will cause this login script to terminate after calling. REM the other batch file. if exist c:tempip.tmp del c:tempip.tmp echo Running Windows Login Script... echo. echo Temporarily removing F drive... echo. net use f: /delete REM Determine Subnet, do things based on SUBNET REM ALL USERS section is where things go that need to happen for all users regardless of subnet. REM for /f "tokens=2 delims=:" %%i in ('ipconfig ^| find /i "IP Address"') do set IP=%% iecho %IP% >> c:tempip.tmp for /f "tokens=3 delims=." %%j in (c:tempip.tmp) do set SUBNET=%%j if %SUBNET%==16 goto 16_SUBNET if %SUBNET%==100 goto 100_SUBNET if %SUBNET%==250 goto 250_SUBNET goto ALL_USERS :16_SUBNET net use F: \{16_subnet_server}share echo Welcome to the 16 subnet! goto ALL_USERS :100_SUBNET net use F: \{100_subnet_server}share echo Welcome to the 100 subnet! goto ALL_USERS :250_SUBNET net use F: \{250_subnet_server}share echo Welcome to the 250 subnet! goto ALL_USERS :ALL_USERS REM Use this section to perform functions that pertain to all users goto END :END
Please let us know how useful you find this tip by rating it below! If you have a useful
Windows tip, timesaver or workaround to share, submit it to our tip contest and you
could win a prize!
This was first published in September 2006
Enterprise Server Strategies for the CIO
Join the conversationComment
Share
Comments
Results
Contribute to the conversation