#67934 - 2002-07-09 09:32 PM
Re: Updates vis Kix ??
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11631
Loc: CA
|
Here futte... mines not as extensive as Bills
But should do the trick as well for just SP levels.
code:
; *** File Name: SPUPDATE.KIX *** v1.0 ; *** Date Created: 2001-11-28 by Ron Lewis (NTDOC) ; *** Last Date Modified: 2001-11-29 7:30 pm PST - By Ron Lewis (NTDOC) ; *** Comments: Checks NT/2000 systems to see if they are on a current Service Pack level ; *** and if it can be installed or not via this logon script based upon prerequisite checks. ; *** This file is called by LOGON.KIX and resides on the master ; *** domain in the \NETLOGON folder of all domain controllers and ; *** in the export directory for the domain PDC ; *** Logging servers for reports and source files are: xxx, xxx, xxx, xxx ; *** NOTE: Code designed for KiXtart v3.63 ; *** The folder SP should be shared from each source server. Then under SP there are 2 folders ; *** NT4 and WIN2K each of those are the expanded Service Packs for each OS under I386 for a common path. ; *** Assumes most users are local administrators of the system. Logs systems where user is not admin for manual updates by ; *** someone who is a local admin.
BREAK ON $logsrv = "xx02" $DiskSpace = GetDiskSpace("C:\") /1024 $SRVR = ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions", "ProductType") $OkToClear = "no" ; Setting to allow deletion of the log files for tracking purposes.
IF (@inwin = 1) $NT_mode="yes" ELSE $NT_mode="no" GOTO END ;System is a Win9x which does not require a Service Pack update. ENDIF
IF INGROUP("\\@WKSTA\Administrators") <>0 ; user is a local admin $RegUse = "HKEY_LOCAL_MACHINE" $IsAdmin = "yes" ELSE $RegUse = "HKEY_CURRENT_USER" ; user is not a local admin $IsAdmin = "no" ENDIF
; Check and create the SPCHECK key if not found. IF (ExistKey("$RegUse\SOFTWARE\mycompany\SPCHECK")) ; If key is found this routine is jumped $nul = AddKey ("$RegUse\SOFTWARE\mycompany\SPCHECK") $nul = WRITEVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","counter", "0", "REG_DWORD") $nul = WRITEVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install", "2", "REG_DWORD") ENDIF
SELECT CASE (SUBSTR(@IPADDRESS0,1,11)) = "170. 16.115" $logsrv = "xx40" $spserver = "xx40" CASE (SUBSTR(@IPADDRESS0,1,7)) = "125.105" $logsrv = "xx02" $spserver = "xx02" CASE (SUBSTR(@IPADDRESS0,1,7)) = "155. 2" $logsrv = "xx50" $spserver = "xx50" CASE 1 $logsrv = "xx02" $spserver = "unknown" ENDSELECT
GOSUB "OSCHECK"
IF $IsAdmin = "no" GOSUB "COUNTER" GOTO LOGFILE ; User is not an Admin so we can't update the Service Pack GOTO END ENDIF IF $DiskSpace < 200 GOSUB "COUNTER" GOTO LOGFILE ; System does not have enough free diskspace to update the Service Pack GOTO END ENDIF
IF $spserver = "unknown" ; Log and quit the update since they may be coming across the WAN instead of the LAN and update will take too long. GOSUB "LOGFILE" GOTO END ENDIF
GOSUB "SPCHECK" GOTO END
:SPCHECK IF ($os_type="W2KTS" OR $os_type="W2K") $os_val = SP\WIN2K\i386 ;Set path variable for using the correct OS Service Pack update. ELSE $os_val = SP\NT4\i386 ENDIF ;Set the switches for the SP update. ; -u=Unattended, -f=Force other apps to close at shutdown, -n=Do not bckup files for uninstall, -o=Overwrite OEM files without prompting ; -z=Do not reboot when installation is complete, -q=Quiet mode - no user interaction (i.e. silent install), -s:<dir>=Integrate Service Pack files into <dir> $UpDate = '%comspec% /c "\\$spserver\$os_val\update\update.exe -u -f"' SELECT CASE ($os_type="W2KTS" OR $os_type="W2K") AND $splevel < 2 GOSUB "LOGFILE" IF $SRVR<>"WinNT" $MsgAlert = MESSAGEBOX("NOTICE: This system is running Windows 2000 Server (SP$splevel) which does not appear to be the latest Service Pack. Please install the latest service pack for this system.", "Service Pack Check", 4112) ELSE IF READVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install")<>"0" ; If setting is 0 then we assume our update has already happened, quit this routine. IF $SRVR="WinNT" IF READVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install")="1" ;If setting is 1 then start the update $nul = WRITEVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install", "0", "REG_DWORD") SHELL $UpDate ELSE $MsgAlert = MESSAGEBOX("NOTICE: This system is running Windows 2000 (SP$splevel) which does not appear to be the latest Service Pack. Would you like to run the update now? (This may take up to 30 minutes or more to complete depending on network speed) If you choose CANCEL, the update will run automatically the next time you logon without asking you. This script will attempt to install the Service Pack update for your system now if you choose OK. Once completed your system will be automatically restarted. Please contact the Helpdesk if you experience any problems. Helpdesk xxx-xxx-xxxx", "Service Pack Check", 4401) IF $MsgAlert = 2 ; User chose CANCEL $nul = WRITEVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install", "2", "REG_DWORD") ;Set value to 2 here, the counter will then set it to 1 for next logon. ELSE $nul = WRITEVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install", "0", "REG_DWORD") ;User chose OK, so start the update and change the Registry value. SHELL $UpDate ;Run SP2 update ENDIF ENDIF ENDIF ENDIF ENDIF CASE ($os_type="NT4") AND $splevel < 6 GOSUB "LOGFILE" IF $SRVR<>"WinNT" $MsgAlert = MESSAGEBOX("NOTICE: This system is running Windows NT 4.0 Server (SP$splevel) which does not appear to be the latest Service Pack. Please install the latest service pack for this system.", "Service Pack Check", 4112) ELSE IF READVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install")<>"0" ; If setting is 0 then we assume our update has already happened, quit this routine. IF $SRVR="WinNT" IF READVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install")="1" ;If setting is 1 then start the update $nul = WRITEVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install", "0", "REG_DWORD") ? "Code is set to 1 SP6a should now start installing" SHELL $UpDate ;Run update code ELSE $MsgAlert = MESSAGEBOX("NOTICE: This system is running Windows NT 4.0 (SP$splevel) which does not appear to be the latest Service Pack. Would you like to run the update now? (This may take up to 30 minutes or more to complete depending on network speed) If you choose CANCEL, the update will run automatically the next time you logon without asking you. This script will attempt to install the Service Pack update for your system now if you choose OK. Once completed your system will be automatically restarted. Please contact the Helpdesk if you experience any problems. Helpdesk xxx-xxx-xxxx", "Service Pack Check", 4401) IF $MsgAlert = 2 ; User chose CANCEL $nul = WRITEVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install", "2", "REG_DWORD") ;Set value to 2 here, the counter will then set it to 1 for next logon. ELSE $nul = WRITEVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install", "0", "REG_DWORD") ;User chose OK, so start the update and change the Registry value. SHELL $UpDate ;Run SP6a update ENDIF ENDIF ENDIF ENDIF ENDIF CASE 1 ;Unknown problem RETURN ENDSELECT IF $OkToClear = "yes" ;Used to delete log files once a system has been updated, otherwise the old log files won't get cleaned up. GOSUB "CLEARLOG" ENDIF GOSUB "COUNTER" RETURN GOTO END
:COUNTER IF $RegUse = "HKEY_CURRENT_USER" ; Don't update install value no software can be installed. We will use counter to see how many times user logs on and log it. $TempCounter = val(READVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","counter"))+1 ; Increments the counter value as a means to see how many times the user logs in. $nul = WRITEVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","counter", "$TempCounter", "REG_DWORD") ENDIF
IF $RegUse = "HKEY_LOCAL_MACHINE" ; Don't update counter value we are going to update install key for the Service Pack update IF READVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install")<>0 ;Once key is at 0 we don't want to try subtracting by -1 as it may corrupt the value $TempInstall = val(READVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install"))-1 $nul = WRITEVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","install", "$TempInstall", "REG_DWORD") ENDIF $TempCounter = val(READVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","counter"))+1 ; Increments the counter value as a means to see how many times the user logs in. $nul = WRITEVALUE("$RegUse\SOFTWARE\mycompany\SPCHECK","counter", "$TempCounter", "REG_DWORD") ENDIF RETURN
:OSCHECK ; Checks the operating system version. NOTICE: Windows 2000 SP3 beta is not supported at this time. System reads it as SP1 $os="" $os_dos=@dos $os_product=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType") $os_productSuite=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductSuite") $os_service_pack="" $os_subversion=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","SubVersionNumber")
SELECT CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.0") AND ($os_productSuite = "Enterprise|Terminal Server|") ; - Windows 2K Terminal Server $os="W2KTS_Terminal_Server" CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.1") ; - Windows XP Server $os="WXP_Server" CASE ($NT_mode = "yes") AND ($os_product = "WinNT") AND ($os_dos = "5.1") ; - Windows XP Professional $os="WXP_Professional" CASE ($NT_mode = "yes") AND ($os_product <> "WinNT") AND ($os_dos = "5.0") ; - Windows 2000 Server $os="W2K_Server" CASE ($NT_mode = "yes") AND ($os_product = "WinNT") AND ($os_dos = "5.0") ; Windows 2000 Professional $os="W2K_Professional" CASE ($NT_mode = "yes") AND ($os_product = "LANMANNT") ; - Windows NT - $os="NT4_Domain_Controller" CASE ($NT_mode = "yes") AND ($os_product = "ServerNT") $os="NT4_Member_Server" CASE ($NT_mode = "yes") AND ($os_product = "WinNT") $os="NT4" CASE ($NT_mode <> "yes") AND (@dos = "4.90") $os="ME" CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") AND (INSTR(LCASE($os_subversion),"c") <> 0) ; - Windows 98 - $os="W98c" CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") AND (INSTR(LCASE($os_subversion),"b") <> 0) $os="W98b" CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") AND (INSTR(LCASE($os_subversion),"a") <> 0) $os="W98a" CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") $os="W98" CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") AND (INSTR(LCASE($os_subversion),"c") <> 0) ; - Windows 95 - $os="W95c" CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") AND (INSTR(LCASE($os_subversion),"b") <> 0) $os="W95b" CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") AND (INSTR(LCASE($os_subversion),"a") <> 0) $os="W95a" CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") $os="W95" CASE 1 $os="???" ; - undetermined - ENDSELECT
$os_service_pack="" IF ($NT_mode = "yes") $os_service_pack=ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion","CSDVersion") IF (len($os_service_pack) <> 0) $os=$os+" SP"+substr($os_service_pack,len($os_service_pack),1) $splevel = substr($os_service_pack,len($os_service_pack),1) ENDIF ENDIF
$os_type="" $os_dos=@dos SELECT CASE ($NT_mode = "yes") AND ($os_dos = "5.0") AND ($os_productSuite = "Enterprise|Terminal Server|") ; - Windows 2000 Terminal Server - $os_type="W2KTS" CASE ($NT_mode = "yes") AND ($os_dos = "5.1") ; - Windows XP - $os_type="WXP " CASE ($NT_mode = "yes") AND ($os_dos = "5.0") ; - Windows 2000 - $os_type="W2K " CASE ($NT_mode = "yes") ; - Windows NT - $os_type="NT4 " CASE ($NT_mode <> "yes") AND ($os_dos = "4.90") ; - Windows ME - $os_type="ME" CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") ; - Windows 98 - $os_type="W98" CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") ; - Windows 95 - $os_type="W95" CASE 1 $os_type="???" ; - undetermined - ENDSELECT $os_type=LTRIM(RTRIM(substr($os_type+" ",1,5))) RETURN
:LOGFILE ; Log system information for tracking purposes. Systems where the user is not a local Admin will require someone with Admin rights to visit the system and update it. $CounterValue = ReadValue("$RegUse\SOFTWARE\mycompany\SPCHECK","counter") IF EXIST ("\\"+$logsrv+"\LOGS\SPCHECK\"+@WKSTA+"."+@ADDRESS+".LOG") DEL ("\\"+$logsrv+"\LOGS\SPCHECK\"+@WKSTA+"."+@ADDRESS+".LOG") ENDIF IF OPEN(1,"\\"+$logsrv+"\LOGS\SPCHECK\"+@WKSTA+"."+@ADDRESS+".LOG", 5)= 0 $out = WriteLine(1, @DATE+"*"+@TIME+"*"+@USERID+"*"+@COMMENT+"*"+$commentNT+"*"+@FULLNAME+"*"+@lserver+"*"+@HOMEDIR+"*"+@HOSTNAME+"*"+@IPADDRESS0+"*"+@ADDRESS+"*"+@WKSTA+"*"+$os+"*"+$DiskSpace+"*"+$IsAdmin+"*"+$CounterValue+"*"+$spserver+"*"+$CRLF) $nul = CLOSE(1) ENDIF RETURN
:CLEARLOG ; Delete log files for systems that are now running the correct Service Pack level. SELECT CASE ($os_type="W2KTS" OR $os_type="W2K") AND $splevel = 2 IF EXIST ("\\"+$logsrv+"\LOGS\SPCHECK\"+@WKSTA+"."+@ADDRESS+".LOG") DEL ("\\"+$logsrv+"\LOGS\SPCHECK\"+@WKSTA+"."+@ADDRESS+".LOG") ENDIF CASE ($os_type="NT4") AND $splevel = 6 IF EXIST ("\\"+$logsrv+"\LOGS\SPCHECK\"+@WKSTA+"."+@ADDRESS+".LOG") DEL ("\\"+$logsrv+"\LOGS\SPCHECK\"+@WKSTA+"."+@ADDRESS+".LOG") ENDIF CASE 1 ;Do nothing ENDSELECT RETURN
:END RETURN
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 483 anonymous users online.
|
|
|