;******************************************************************
;* DOMAIN LOGIN SCRIPT *
;* WRITTEN IN KIX32 SCRIPT LANGUAGE *
;* *
;******************************************************************

;******************************************************************
;Revision log
;ALWAYS A GOOD PRACTICE TO PUT IN NAME OR INITIALS AND CHANGES
;MADE SO THAT ANY BUGS IN THE SCRIPT CAN BE EASILY TRACKED DOWN
;AND CHANGED.

;******************************************************************

;******************************************************************
;* Set Initial environment *
;******************************************************************

setconsole ("minimize") ; hide kix start box
;set KXRPC=\\<servername>
;Variables
$LF = chr(13) + chr(10)
$TRUE = 1
$FALSE = 0

;******************************************************************
;* Run OS Check *
;******************************************************************

$OSVer = @INWIN

;******************************************************************
;* Debug flag *
;* Change DebugON = TRUE to show debug msgs *
;* Or use kix32 logon $DebugON=1 from cmd line
;******************************************************************
;$DebugON = TRUE

;******************************************************************
;* Message Only flag *
;* Change UsrMsgONLY to True to jump to User Message *
;* used during the debug process
;******************************************************************
$UsrMsgONLY = FALSE
;$UsrMsgONLY = TRUE

;******************************************************************
;* KIX ReInstall flag *
;* Change KIXNewInstall to True to install new KIX version *
;******************************************************************
$KIXNewInstall = FALSE
;$KIXNewInstall = TRUE

;******************************************************************
;* WRQ ReInstall flag *
;* Change WRQNewInstall to True to always install WRQ 2000 client *
:* used WRQ Express 2000 to monitor Y2k compliance *
;******************************************************************
$WRQNewInstall = FALSE
;$WRQNewInstall = TRUE

;Set local time using server
SETTIME @lserver

;******************************************************************
;* Set User Locale *
;******************************************************************
$Locale = ucase(substr(@wksta,1,8))

if $DebugON
? $Locale ?
endif

select
case $Locale = "LOCALE1"
$HomeServer = "\\LOCALE1" ;USUALLY A BDC
;KIX seems to have an error when I remove this and try to use copy later in the script???
copy "$HomeServer\netlogon\files\winipcfg.lnk" "c:\windows\desktop\"

case $Locale = "LOCALE2"
$HomeServer = "\\LOCALE2"
copy "$HomeServer\netlogon\files\winipcfg.lnk" "c:\windows\desktop\"

case $Locale = "LOCALE3"
$HomeServer = "\\LOCALE3"

case $Locale = "LOCALE4"
$HomeServer = "\\LOCALE4"

;Default
case 1
$HomeServer = "\\LOCALE1"
copy "$HomeServer\netlogon\files\winipcfg.lnk" "c:\windows\desktop\"

endselect

;******************************************************************
;* Setup Local Environment *
;******************************************************************

;Map user drive to Z:, if it exist on HomeServer
if exist ("$HomeServer\@userid$$")
use z: /DEL
use z: "$HomeServer\@userid$$"
endif

if $DebugON
if @ERROR = 0
? "User Dir = $HomeServer\@userid$$" ?
endif
endif

;*** FUTURE TODO *** Add group specific drive mappings here

;******************************************************************
;* Format IP Address *
;******************************************************************

;Format the IP Address to remove padding as default looks ugly
$IPHostAddress =
ltrim(substr(@ipaddress0,1,3)) + "."
+ ltrim(substr(@ipaddress0,5,3)) + "."
+ ltrim(substr(@ipaddress0,9,3)) + "."
+ ltrim(substr(@ipaddress0,13,3))

if $DebugON
? $IPHostAddress ?
endif

;******************************************************************
;* CHECK FOR RAS CONNECTION *
;******************************************************************
; TO CHECK FOR RAS OR OTHER TYPE OF CONNECTION***
if @RAS
if $DebugON
? "RAS True" ?
endif

$ModemUser = TRUE
;***WHAT TYPE OF REMOTE ACCESS
$IPHostValue = val(substr($IPHostAddress, len($IPHostAddress)- 2, 3 ))

if $DebugON
? $IPHostValue ?
endif

;***RAS DIAL-IN RANGE CURRENTLY XXX.XXX.XXX.XXX
if $IPHostValue > 220
$Modem = "RAS"
else
$Modem = "OTHER"
endif

else
if $DebugON
? "RAS FALSE" ?
endif
$ModemUser = FALSE
endif

;******************************************************************
;* 95 Specific Items *
;******************************************************************
if $OSVer = 2

if $DebugON
? "Windows 95" ?
endif

$OS = "Windows 95"

;copy "$HomeServer\netlogon\files\winipcfg.lnk" "c:\windows\desktop\"

if exist ("c:\windows\system\lmscript.old")
$FilesCopied = TRUE
else
$FilesCopied = FALSE
endif

if ($KIXNewInstall ) OR ($FilesCopied = FALSE)
copy "$HomeServer\netlogon\files\kix32.exe" "c:\windows\system\kix32.exe"
copy "$HomeServer\netlogon\files\kx32.dll" "c:\windows\system\kx32.dll"
copy "$HomeServer\netlogon\files\kx16.dll" "c:\windows\system\kx16.dll"
copy "$HomeServer\netlogon\files\kx95.dll" "c:\windows\system\kx95.dll"
copy "c:\windows\system\lmscript.exe" "c:\windows\system\lmscript.old"
copy "c:\windows\system\kix32.exe" "c:\windows\system\lmscript.exe"
endif

;Set Workgroup
writevalue ("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\VNETSUP","Workgroup","WORKGROUPNAME","REG_SZ")
if $DebugON
if @ERROR = 0
? "Value written to the registry"
endif
endif

;THIS VALUE IS USED SO THAT A USER MUST BE VALIDATED BY THE NETWORK IN ORDER
;TO GAIN ACCESS TO THE COMPUTER
;ONE NOTE IS THAT EVEN ADMINISTRATORS CANNOT ACCESS THE WORKSTATION
;BUT HAVE TO START UP THE COMPUTER IN SAFE MODE AND EDIT THE REGISTRY AND
;DELETE THIS KEY AND THEN RESTART THE COMPUTER TO WORK ON IT.

if $ModemUser = FALSE
;Must login to use Windows
writevalue ("HKEY_LOCAL_MACHINE\Network\Logon","MustBeValidated","1","REG_DWORD")
if $DebugON
if @ERROR = 0
? "Value written to the registry"
endif
endif
endif

endif

;******************************************************************
;* Check for UsrMsgONLY Flag *
;******************************************************************
if $DebugON
? "User Message Flag" ?
endif

if ($UsrMsgONLY = TRUE) OR ($ModemUser = TRUE)
if DebugON
? "Jump to User Message" ?
endif
goto "usrmsg"
endif

;******************************************************************
;* Run WRQ Express Installer *
;******************************************************************
:wrqclient
if $DebugON
? "WRQ Express 2000" ?
endif

;THIS IS WHERE AN ENTRY IS WRITTEN INTO A LOG FILE TO SHOW
;THAT THE CLIENT HAS BEEN INSTALLED ON A WORKSTATION

;Log Execution
if Open( 3 , "$HomeServer\reports$$\WRQClient.log" , 5 ) = 0
$Buffer = "@date,@time,"
+ "WRQCLIENT,@userid,@fullname,@wksta,$HomeServer" + $LF
$x = WriteLine( 3 , $Buffer)
Close (3)
else
if $DebugON
? "failed to open file, error code : [" + @ERROR + "]"
endif
endif

if $WRQNewInstall = TRUE
run "$HomeServer\y2k$\clients\exinst.exe -A -Q"
else
run "$HomeServer\y2k$\clients\exinst.exe -Q"
endif

;Force Y2K testing
;if exist("c:\windows\system\exinv32.exe")
; run "c:\windows\system\exinv32.exe -BMnft -BY2K"
;endif

;******************************************************************
;* Windows NT *
;******************************************************************
;Jump to User Message if running NT
;Patches are only for Windows 95

if $OSVer = 1

if $DebugON
? "Windows NT" ?
endif

$OS = "Windows NT"

goto "usrmsg"

endif

;******************************************************************
;* Run WIN 95 Service Pack 1 *
;******************************************************************

if $DebugON
? "Win 95 Service Pack 1" ?
endif

$Message = "Hello, @fullname!" + $LF + $LF
+ "In order to prepare your workstation for the Year 2000, " + $LF
+ "software patches must be applied at this time." + $LF + $LF
+ "This software installation should only take a few minutes, " + $LF
+ "but should you have any questions or problems, " + $LF
+ "please contact: " + $LF + $LF
+ " TECHNICAL SERVICE CENTER " + $LF
+ " (904)332-1867" + $LF + $LF
+ "Thank you." + $LF

;
;CHECK FOR THE EXISTANCE OF THIS FILE TO RUN THE 95 SP1.
;

if exist ("c:\windows\inf\sp1unins.inf")
goto "winsock2"
else
messagebox ($Message,"Software Update: Windows 95 Service Pack 1", 4144,60)

run "$HomeServer\netlogon\files\w95setup.exe"

;ADDS AN ENTRY FOR INSTALLATION OF WIN 95 SP1

;Log Execution
if Open( 3 , "$HomeServer\reports$$\update.log" , 5 ) = 0
$Buffer = "@date,@time,"
+ "W95SP1,@userid,@fullname,@wksta,$HomeServer" + $LF
$x = WriteLine( 3 , $Buffer)
Close (3)
else
if $DebugON
? "failed to open file, error code : [" + @ERROR + "]"
endif
endif
sleep 20
endif

;******************************************************************
;* Run WIN 95 Winsock 2 Update *
;******************************************************************

:winsock2
if $DebugON
? "Winsock 2 Update" ?
endif

;CHECK FOR THE EXISTANCE OF THIS FILE TO RUN THE 95 WINSOCK2 UPDATE.

if exist ("c:\windows\ws2bakup\ws2bakup.bat")
goto "win95y2k"
else
messagebox ($Message,"Software Update: Windows 95 Winsock Patch", 4144,60)

run "$HomeServer\netlogon\files\winsock2.exe /Q:1"

;ADDS AN ENTRY FOR INSTALLATION OF WIN 95 WINSOCK 2

;Log Execution
if Open( 3 , "$HomeServer\reports$$\update.log" , 5 ) = 0
$Buffer = "@date,@time,"
+ "WINSOCK2,@userid,@fullname,@wksta,$HomeServer" + $LF
$x = WriteLine( 3 , $Buffer)
Close (3)
else
if $DebugON
? "failed to open file, error code : [" + @ERROR + "]"
endif
endif
sleep(20)
endif

;******************************************************************
;* Run WIN 95 Y2K update *
;******************************************************************
:win95y2k

;CHECK FOR THE EXISTANCE OF THIS FILE TO RUN THE 95 Y2K UPDATE

if exist ("c:\windows\inf\qfe\w95y2kun.inf")
goto "virupd"
else
messagebox ($Message,"Software Update: Windows 95 Year 2000 Patch", 4144,60)

run "$HomeServer\netlogon\files\win95y2k.exe /q"

;ADDS AN ENTRY FOR INSTALLATION OF WIN95 Y2K UPDATE

;Log Execution
if Open( 3 , "$HomeServer\reports$$\update.log" , 5 ) = 0
$Buffer = "@date,@time,"
+ "W95Y2K,@userid,@fullname,@wksta,$HomeServer" + $LF
$x = WriteLine( 3 , $Buffer)
Close (3)
else
if $DebugON
? "failed to open file, error code : [" + @ERROR + "]"
endif
endif
sleep 20
endif

;******************************************************************
;* Reboot of System for Changes *
;******************************************************************

;THE ONLY WAY THAT I HAVE FOUND TO SUCCESSFULLY REBOOT THE SYSTEM
;IS TO USE A PROGRAM LIKE WINEXIT AND TO WRITE A KEY IN THE
;REGISTRY UNDER THE RUNONCE TREE. THIS WORKS AS THE SYSTEM
;HAS LOGGED IN AND IS NOW LOADING ALL OF THE ASSOCIATED REGISTRY
;VALUES. IT THEN CHECKS THE REGISTRY VALUE "RUNONCE" AND EXECUTES
;THAT COMMAND. AFTER THE SYSTEM REBOOTS THAT KEY WILL NO LONGER
;BE THERE.

messagebox ("Your workstation will reboot after network logon to
complete the software update.","Software Update: System Reboot", 4144,60)

;make entry into local y2k patch report log

if exist ("c:\windows\y2krpt.txt")
goto "virupd"
else
;Log Execution
if Open( 3 , "c:\windows\y2krpt.txt" , 5 ) = 0
$Buffer = "@date,@time,"
+ "W95Y2K,@userid,@fullname,@wksta,$HomeServer"
$x = WriteLine( 3 , $Buffer)
Close (3)
else
if $DebugON
? "failed to open file, error code : [" + @ERROR + "]"
endif
endif

endif

copy "$HomeServer\netlogon\files\winexit.exe" "c:\windows\system\"
writevalue ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce",
"winexit.exe",
"c:\windows\system\winexit.exe -fr",
"REG_SZ")

if $DebugON
if @ERROR = 0
? "Value written to the registry"
endif
endif

sleep 5
;******************************************************************
;* Run Anti-Virus Updates *
;******************************************************************

:virupd


;******************************************************************
;* Message to USER *
;******************************************************************

:usrmsg


$Greeting = "Good Morning, "

$HourNow = VAL(SUBSTR(@time,1,2))
if $DebugON
? $HourNow ?
endif

if $HourNow > 11
$Greeting = "Good Afternoon, "
endif

if $HourNow > 17
$Greeting = "Good Evening, "
endif

if $DebugON
? $Greeting ?
endif

$LoginMessage = $Greeting + "@fullname" + $LF
+ "Today is @day, @month @mdayno, @year" + $LF
+ "The time is @time" + $LF + $LF
+ "Logon Server: @lserver" + $LF
+ "Workstation: @wksta" + $LF
+ "Home Server: $HomeServer" + $LF
+ "Network Address: $IPHostAddress" + $LF + $LF

if $ModemUser = TRUE
$LoginMessage = $LoginMessage + "REMOTE USER VIA MODEM - " + $Modem + $LF + $LF
endif

$LoginMessage = $LoginMessage

+ "PLEASE READ THE FOLLOWING NOTICE" + $LF + $LF
+ "This system is intended for business use ONLY. " + $LF
+ "All data contained herein is considered confidential" + $LF
+ "and proprietary." + $LF + $LF
+ "Unauthorized access, use, modification, destruction or" + $LF
+ "disclosure of information supported by this system may" + $LF
+ "result in prosecution." + $LF + $LF
+ "WARNING: ALL TRANSACTIONS ARE LOGGED" + $LF + $LF
+ "Do you understand the above statement?" + $LF + $LF

$answer = messagebox ($LoginMessage, "User: @userid", 4116)

if $answer = 7
? $answer ?
;User selected No
if Open( 3 , "$HomeServer\reports$$\logon.log" , 5 ) = 0
$Buffer = "@date,@time,"
+ "LOGOFF,@userid,@fullname,@wksta,@lserver," + $IPHostAddress + $LF
$x = WriteLine( 3 , $Buffer)
Close (3)
else
if $DebugON
? "failed to open file, error code : [" + @ERROR + "]"
endif
endif
LogOff(1)
goto "Done"
else
if Open( 3 , "$HomeServer\reports$$\logon.log" , 5 ) = 0
$Buffer = "@date,@time,"
+ "LOGON,@userid,@fullname,@wksta,@lserver," + $IPHostAddress + $LF
$x = WriteLine( 3 , $Buffer)
Close (3)
else
if $DebugON
? "failed to open file, error code : [" + @ERROR + "]"
endif
endif
endif

;******************************************************************
;* Message of the Day *
;******************************************************************
;
;THIS CAN BE USED TO ANNOUNCE MESSAGES OF THE DAY IE. SERVER
;MAINTENANCE, PLANNED OUTAGES, NEW SERVICES ETC.

$Today = substr(@date,1,4) + substr(@date,6,2) + substr(@date,9,4)
if $DebugON
? $Today ?
endif

$MOTDFile = "$HomeServer\netlogon\motd\" + $Today + ".txt"

if $DebugON
? "Message of the day file =" + $MOTDFile ?
endif

$x = ""
$stars = $LF + "************************************************************************" + $LF
$buffer = $stars

if Open( 3 , "$MOTDFile") = 0
$x = ReadLine(3) + $LF
while @ERROR = 0
$buffer = $buffer + $x
$x = ReadLine(3) + $LF
loop
Close (3)

$buffer = $buffer + $stars

Messagebox ($buffer, "Message of the Day for @day, @month @mdayno, @year", 4160, 360)
else
if $DebugON
? "failed to open file, error code : [" + @ERROR + "]"
endif
endif

;******************************************************************
;* Done *
;******************************************************************
one
COOKIE1
if $DebugOn
? "Exit" ?
endif
EXIT

The script looks a little bad here but check
it out... its a great script.