Intelligent Logon-script

Main Logon-script

This is the script which should be called upon logon (see user's settings in AD).

ai_logon.cmd
@echo off
setlocal
 
set AIT=[AI]
set AI_SERVER=%LOGONSERVER%
set AI_PROFILES=%AI_SERVER%\profiles$\
set AI_PROFILESTS=%AI_SERVER%\profilests$\
 
set AI_PROFROOT=%AI_PROFILES%
if not x%SESSIONNAME%x==xConsolex set AI_PROFROOT=%AI_PROFILESTS%
set AI_LOG=%AI_PROFROOT%_logs\%USERNAME%.log
 
if exist %AI_LOG% del %AI_LOG%
 
title %AIT% AI-Logon-Script --- Erstellt von Markus Birth (markus@birth-online.de)
echo AI-Logon-Script --- Erstellt von Markus Birth (markus@birth-online.de)
echo AI-Logon initiated. >%AI_LOG%
echo.
echo %DATE% / %TIME%
echo Ihr Login-Name: %USERNAME%
echo Ihr Computer: %COMPUTERNAME%
echo Logon-Server: %LOGONSERVER%
echo.
 
title %AIT% Benutzererkennung...
call "u_%USERNAME%.cmd"
 
if NOT x%AI%x==xx goto usercont
title %AIT% Benutzer unbekannt.
echo.
echo Ihre Identitaet konnte nicht festgestellt werden.
echo.
echo Bitte wenden Sie sich an den Systemadministrator und halten Sie Ihre
echo Benutzerkennung (%USERNAME%) bereit.
echo.
pause
goto end
 
:usercont
set AIT=%AIT% %AI_NAME% ---
title %AIT% Logon laeuft...
cls
echo **************************************************************************
echo Guten Tag, %AI_TITL% %AI_NAME%!
echo.
echo B I T T E     W A R T E N     S I E
echo.
echo Es geht gleich los...
echo **************************************************************************
echo Aktuelle Uhrzeit . . .: %DATE% / %TIME%
echo Ihr Login-Name . . . .: %USERNAME%
echo Ihr Computer . . . . .: %COMPUTERNAME%
echo Ihr Profilverzeichnis.: %USERPROFILE%
echo Ihr Name . . . . . . .: %AI_NAME%
echo Ihr Namenkuerzel . . .: %AI_DIRS%
echo Ihr NetFolder. . . . .: %AI_NETF%
echo **************************************************************************
 
call _default.cmd
for %%f in (%AI_SERVER%\NETLOGON\a_*.cmd) do call %%f
title %AIT% Alle Module ausgefuehrt.
echo Alle Module ausgefuehrt.>>%AI_LOG%
goto end
 
:end
title %AIT% Logon-Script fertig.
echo AI-Logon-Script done.>>%AI_LOG%
endlocal
echo.
echo Logon-Script fertig.
:exit
title %comspec%

Default actions

The called _default.cmd with default actions:

_default.cmd
title %AIT% Standard-Aktionen...
echo Standard-Aktionen werden durchgefuehrt.
 
set AI_FROM=%CLIENTNAME% via %COMPUTERNAME%
if x%CLIENTNAME%x==xx set AI_FROM=%COMPUTERNAME%
echo Logon: %USERNAME% at %DATE% / %TIME% on %LOGONSERVER% from %AI_FROM% >>%AI_LOG%
echo Standard-Aktionen... >>%AI_LOG%
 
%windir%\system32\net use o: %AI_SERVER%\Dokumente /persistent:no >>%AI_LOG% 2>&1
:Laufwerk U: = %AI_SERVER%\Profiles$\%AI_DIRS% = Basisordner via ActiveDirectory-Benutzerverwaltung
%windir%\system32\net use z: %AI_SERVER%\EURODRINK /persistent:no >>%AI_LOG% 2>&1
 
if exist "%AI_PROFROOT%_default.done\_%AI_DIRS%.done" goto skipprop
 
echo Standard-Dateien propagieren... >>%AI_LOG%
xcopy "%AI_PROFROOT%_default\*.*" "%USERPROFILE%\" /S /V /C /I /F /H /K /Y >>%AI_LOG% 2>&1
echo Standard-Dateien propagiert. >>%AI_LOG%
 
echo Updated: %DATE% / %TIME%.>%AI_PROFROOT%_default.done\_%AI_DIRS%.done
 
:skipprop
 
if NOT exist _default.reg goto skipreg
echo Standard-Registrywerte importieren... >>%AI_LOG%
regedit /s _default.reg >>%AI_LOG% 2>&1
echo Standard-Registrywerte importiert. >>%AI_LOG%
 
:skipreg
 
echo Standard-Aktionen fertig.
echo Standard-Aktionen fertig. >>%AI_LOG%
title %AIT% Standard-Aktionen... fertig.

Internet settings

A module a_internet.cmd which sets internet settings:

a_internet.cmd
title %AIT% Internetberechtigung setzen...
echo Internetberechtigung... >>%AI_LOG%
echo Internetberechtigung wird gesetzt.
if x%AI_INET%x==xx goto lockinet
 
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v NoNetAutodial /t REG_DWORD /d 0 /f >>%AI_LOG% 2>&1
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f >>%AI_LOG% 2>&1
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyHttp1.1 /t REG_DWORD /d 1 /f >>%AI_LOG% 2>&1
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d 127.0.0.1:8080 /f >>%AI_LOG% 2>&1
 
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap" /v ProxyByPass /t REG_DWORD /d 0 /f >>%AI_LOG% 2>&1
 
echo Internet erlaubt>>%AI_LOG%
goto end
 
 
:lockinet
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v NoNetAutodial /t REG_DWORD /d 0 /f >>%AI_LOG% 2>&1
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f >>%AI_LOG% 2>&1
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyHttp1.1 /t REG_DWORD /d 1 /f >>%AI_LOG% 2>&1
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d 127.0.0.1:8080 /f >>%AI_LOG% 2>&1
 
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap" /v ProxyByPass /t REG_DWORD /d 0 /f >>%AI_LOG% 2>&1
 
echo Internet gesperrt>>%AI_LOG%
goto end
 
 
:end
title %AIT% Internetberechtigung setzen... fertig.
echo Internetberechtigung gesetzt.
echo Internetberechtigung gesetzt. >>%AI_LOG%

Time settings

This is the a_time.cmd:

a_time.cmd
title %AIT% Zeitabgleich...
echo Zeitabgleich mit dem Server. (%DATE% / %TIME%)
echo Zeitabgleich (%DATE% / %TIME%)... >>%AI_LOG%
 
%windir%\system32\net time %AI_SERVER% /set /yes >>%AI_LOG% 2>&1
 
echo Zeitabgleich fertig.         (%DATE% / %TIME%)
echo Zeitabgleich fertig.(%DATE% / %TIME%) >>%AI_LOG%
 
title %AIT% Zeitabgleich... fertig.

Userdata

User's preferences are set in files u_username.cmd, like this one u_mbirth.cmd for the user mbirth (me ;-) ):

u_marbir.cmd
set AI=1
set AI_TITL=Herr
set AI_NAME=Markus Birth
set AI_DIRS=marbir
set AI_NETF=marbir$
 
set AI_ADMIN=1
set AI_INET=1
 
snippets/cmd/ailogon.txt · Last modified: 2010-01-15 14:48.06 by mbirth
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki Contents powered by Club-Mate Contents powered by BassDrive.com Labelled with ICRA