#65461 - 2002-05-16 01:36 AM
LOGON.BAT (the overkill version)
|
Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
|
I've created this LOGON.BAT to be as flexible as possible. Thus, it's a little bit big (3KB) but it seems to work well in my network. I haven't been able to test it under Windows XP, though. This script will take care of those instances where a normal user logs into a Windows 2000/XP computer where KiXtart has not been installed locally. Normally, copying into the %WINDIR% folder requires administrative privileges, so the login script will not be able to do so for a regular user. Additionally, if for whatever reason the KiXtart executable cannot be found in either %WINDIR% or the NETLOGON folder, an error message is displayed and an alert is sent to the Systems Administrator. Comment and bug reports welcome and encouraged!!
code:
@ECHO OFF CLS
ECHO Verifying / Updating Script Software Installation
SETLOCAL
REM detect the operating system and go to the appropriate segment
VER | find "NT" > nul IF not errorlevel 1 GOTO Win_NT
VER | find "2000" > nul IF not errorlevel 1 GOTO Win_2K
VER | find "XP" > nul IF not errorlevel 1 GOTO Win_XP
VER | find "98" > nul IF not errorlevel 1 GOTO Win_98
VER | find "95" > nul IF not errorlevel 1 GOTO Win_95
VER | find "Millennium" > nul IF not errorlevel 1 GOTO WIN_ME
GOTO DOS
REM client is running DOS :DOS ECHO. ECHO No Login Script Available For DOS Clients ECHO. GOTO End
REM client is running Windows 9x :Win_95 :Win_98 :Win_ME %WINDIR%\COMMAND\XCOPY %0\..\KIX32.EXE %WINDIR%\ /D /H /I /R /V /C > NUL %WINDIR%\COMMAND\XCOPY %0\..\KX*.DLL %WINDIR%\ /D /H /I /R /V /C > NUL GOTO RunScript
REM client is running Windows NT/2000 :Win_NT :Win_2K :Win_XP ECHO y| XCOPY %0\..\KIX32.EXE %WINDIR%\ /D /H /I /R /V /C > nul GOTO RunScript
REM client is running Windows XP REM the DEL command removes any Kixtart file from the %WINDIR%\SYSTEM32 directory ECHO y| XCOPY %0\..\KIX32.EXE %WINDIR%\ /D /H /I /R /V /C > nul GOTO RunScriptXP
REM run the logon script for Windows 9x/ME/NT/2K :RunScript ECHO. ECHO Loading Logon Script, Please Wait... ECHO.
REM check whether Kixtart is installed locally IF EXIST %WINDIR%\KIX32.EXE GOTO LocalExe IF EXIST %0\..\KIX32.EXE GOTO RemoteExe GOTO KixtartError
REM Kixtart is not installed locally :RemoteExe %0\..\KIX32.EXE %0\..\LOGIN.KIX GOTO End
REM Kixtart is installed locally :LocalExe %WINDIR%\KIX32.EXE %1 %0\..\LOGIN.KIX GOTO End
REM run the logon script for Windows 9x/ME/NT/2K :RunScriptXP ECHO. ECHO Loading Logon Script, Please Wait... ECHO.
REM check whether Kixtart is installed locally IF EXIST %WINDIR%\KIX32.EXE GOTO LocalExeXP IF EXIST %0\..\KIX32.EXE GOTO RemoteExeXP GOTO KixtartError
REM Kixtart is not installed locally :RemoteExeXP KIX32.EXE LOGIN.KIX GOTO End
REM Kixtart is installed locally :LocalExeXP %WINDIR%\KIX32.EXE LOGIN.KIX GOTO End
:End ECHO. ECHO. ECHO Finishing Login...
@ECHO OFF CLS EXIT 0
:KixtartError REM Display an error message and notify the systems Administrator since the user won't be doing it anyway ECHO. ECHO Error loading the NMRC-NT logon script ECHO. ECHO Please notify the Systems Administrator! ECHO. NET SEND REDPOINT "Error loading the NMRC-NT logon script for user "%USERNAME%" on computer "%COMPUTERNAME% >nul PAUSE GOTO End
[ 20. January 2003, 21:55: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.
|
Top
|
|
|
|
#65462 - 2002-05-16 02:54 AM
Re: LOGON.BAT (the overkill version)
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Try this one on... code:
@ECHO OFF
:: Set environment variables SET A=CRC: SET C=Xcopy SET D=Xcopy ERROR: SET L=%Temp%\Logon.log SET C1=CRC32.exe SET K1=kix32.exe SET KixPath=%0\..\kix32\402 SET UtilPath=%0\..\utils SET COPYCMD=/Y SET CORPRUN=-prd SET LOCALRUN=-prd if EXIST %windir%\corp.tst SET CORPRUN=-tst if EXIST %windir%\local.tst SET LOCALRUN=-tst
echo Start logon script batch file >%L% echo.
:: Determine OS IF '%OS%'=='Windows_NT' GOTO WinNT
SET windir= SET windir= IF '%windir%'=='' SET OS=DOS IF '%OS%'=='' IF '%windir%'=='' SET OS=Windows_3.x IF '%OS%'=='' SET OS=Win9x IF '%OS%'=='Win9x' GOTO Cont
echo DOS and Windows 3.x are not supported! pause goto End
:WinNT date<nul >>%L% echo. >>%L% time<nul >>%L% echo. >>%L% echo PROCESSOR_ARCHITECTURE=%PROCESSOR_ARCHITECTURE% >>%L% IF NOT '%PROCESSOR_ARCHITECTURE%'=='x86' Echo Only x86 Architecture is supported. >>%L% IF NOT '%PROCESSOR_ARCHITECTURE%'=='x86' GOTO End
:Cont
Set G=%Temp% IF '%OS%'=='Win9x' Set G=%windir=%
:: Perform CRC check of CRC32.exe, replace file if necessary echo. >>%L% set F=%C1% if NOT EXIST %G%\%C1% %C% %UtilPath%\%F% %G%\ >>%L% echo %A% %G%\%F% >>%L% %G%\%C1% -v 40960 17930e8e %G%\%F% >>%L% if errorlevel 1 echo %A% %C% %UtilPath%\%F% %G%\ >>%L% if errorlevel 1 %C% %UtilPath%\%F% %G%\ >>%L% if errorlevel 1 echo %D% %errorlevel% >>%L% echo. >>%L%
:: Perform CRC check of Kix32.exe, replace file if necessary set F=%K1% echo %A% %G%\%F% >>%L% %G%\%C1% -v 204800 aff4a2b9 %G%\%F% >>%L% if errorlevel 1 echo %A% %C% %KixPath%\%F% %G%\ >>%L% if errorlevel 1 %C% %KixPath%\%F% %G%\ >>%L% if errorlevel 1 echo %D% %errorlevel% >>%L% echo. >>%L%
IF '%OS%'=='Win9x' GOTO Win9x goto Exec
:Win9x SET F=kx16.dll echo %A% %G%\%F% >>%L% %G%\%C1% -v 47104 9777a905 %G%\%F% >>%L% if errorlevel 1 echo %A% %C% %KixPath%\%F% %G%\ >>%L% if errorlevel 1 %C% %KixPath%\%F% %G%\ >>%L% if errorlevel 1 echo %D% %errorlevel% >>%L% echo. >>%L%
SET F=kx32.dll echo %A% %G%\%F% >>%L% %G%\%C1% -v 49152 98fb4015 %G%\%F% >>%L% if errorlevel 1 echo %A% %C% %KixPath%\%F% %G%\ >>%L% if errorlevel 1 %C% %KixPath%\%F% %G%\ >>%L% if errorlevel 1 echo %D% %errorlevel% >>%L% echo. >>%L%
SET F=kx95.dll echo %A% %G%\%F% >>%L% %G%\%C1% -v 49152 61cd8e0f %G%\%F% >>%L% if errorlevel 1 echo %A% %C% %KixPath%\%F% %G%\ >>%L% if errorlevel 1 %C% %KixPath%\%F% %G%\ >>%L% if errorlevel 1 echo %D% %errorlevel% >>%L% echo. >>%L%
:Exec SET F=Libr%CORPRUN%.kix echo %A% %G%\%F% >>%L% %G%\%C1% -v 19692 4d1ac46f %G%\%F% >>%L% if errorlevel 1 echo %A% %C% %0\..\%F% %G%\ >>%L% if errorlevel 1 %C% %0\..\%F% %G%\ >>%L% if errorlevel 1 echo %D% %errorlevel% >>%L% echo. >>%L%
SET F=Corp%CORPRUN%.kix echo %A% %G%\%F% >>%L% %G%\%C1% -v 30728 b673333a %G%\%F% >>%L% if errorlevel 1 echo %A% %C% %0\..\%F% %G%\ >>%L% if errorlevel 1 %C% %0\..\%F% %G%\ >>%L% if errorlevel 1 echo %D% %errorlevel% >>%L% echo. >>%L%
echo %G%\%K1% %0\..\boot%CORPRUN%.kix $Script=corp $SPath=%G% >>%L% %G%\%K1% %0\..\boot%CORPRUN%.kix $Script=corp $SPath=%G%
:END echo End of corp-prd.bat >>%L% SET A= SET C= SET D= SET F= SET G= SET L= SET C1= SET K1= SET KixPath= SET UtilPath= SET COPYCMD= SET CORPRUN= SET LOCALRUN=
[ 17. August 2003, 20:41: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#65463 - 2002-09-05 07:47 AM
Re: LOGON.BAT (the overkill version)
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11624
Loc: CA
|
Dang Howard... LOL
Is that an overkill batch or what. Hehehe have not seen that much overkill since DOS 5.0 days.
Good job though.
|
Top
|
|
|
|
#65464 - 2002-09-05 11:28 AM
Re: LOGON.BAT (the overkill version)
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
IF the users logs on locally, (homeusers)
Forgot the cmd commands is this possible ?
code:
; Check logon server
IF %LOGONSERVER% = %COMPUTERNAME% ? "local logon change start string" nbtstat -RR path=\\pdc\NETLOGON @echo off %systemdrive%\kix32.exe \\pdc\netlogon\start.kix ENDIF
\erik
|
Top
|
|
|
|
#65465 - 2002-09-06 12:31 AM
Re: LOGON.BAT (the overkill version)
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Two equal signs: IF '%LOGONSERVER%' == '%COMPUTERNAME%'
The path statement is not correct. path=%path%;\\pdc\netlogon
You don't want the remote location first in the path or the client will also go the server before looking locally for a file.
How do you expect to have this execute? [ 05. September 2002, 13:38: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#65466 - 2002-09-05 01:10 PM
Re: LOGON.BAT (the overkill version)
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
if the client logs on localy the logon server is the computername.
I would like to check it, but do not know the syntax.
Office User starting string code:
ECHO Starting Login script........ %systemdrive%\kix32.exe start.kix
Homeuser starting string code:
%systemdrive%\kix32.exe \\pdc\netlogon\start.kix
Its executed and working
Today Im using "standalone" cmd file thats requires the User to dubbel click to recive the logon script Then I got the Idea of separting depending on log on server.
But I dont now if its possible
\€rik
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 700 anonymous users online.
|
|
|