Anonymous
Anonymous
Unregistered
|
I appologize once again for the the unusual post, I think I have got everything worked out now. Here is the code I'm working with now, many thanks for Doc for posting the code for W2KSP4 and XPSP1a. I've had to modify it to work in my enviroment here, if anyone has any suggestions as to how I can shorten the script I would greatly appreciate it.
Break on
ServicePackUpdate
Function ServicePackUpdate() Dim $FreeSpace,$spPath,$TimeStop,$TimeStart,$TimeLapse,$UID,$SPAlert,$WR Dim $LogServer,$UserDomain,$CloseFile,$Out,$Defer,$MarkReg Dim $log,$A,$B,$FirstAlert, $SecondAlert Dim $iparray[9],$ipaddress,$spServer $A = " Due to recent viruses and other security threats @CRLF" $A = $A+" it has become necessary to update your systems Service Pack. " $A = $A+"@CRLF You may opt one time not to install this update, however " $A = $A+"the next time you @CRLF logon it will run automatically. This " $A = $A+"update will take approximately 30 minutes @CRLF to complete. If " $A = $A+"you experience any issues with this update, please contact your @CRLF" $A = $A+" schools principal. @CRLF @CRLF Please click YES to continue and " $A = $A+"run the update @CRLF or click NO to cancel and run the update the next" $A = $A+" time you logon." $B = " Your Service Pack will now be updated. @CRLF This update" $B = $B+" may take up to 30 minutes or more to complete. @CRLF @CRLF" $B = $B+" Please DO NOT run any other applications as the computer will " $B = $B+"automatically reboot when the update has completed. @CRLF @CRLF @CRLF" $B = $B+" Please press the OK button to continue." $FirstAlert = $A $SecondAlert = $B $LogServer = '\\e285000n2'
Call "isiniprange.udf" $ipaddress=@IPADDRESS0 $iparray[0]='10.125.16.0/20' If isiniprange($ipaddress,$iparray) $spServer='e285000n2' Goto WinVer EndIf $iparray[1]='10.125.32.0/20' If isiniprange($ipaddress,$iparray) $spServer='e285050n1' Goto WinVer EndIf $iparray[2]='10.125.48.0/20' If isiniprange($ipaddress,$iparray) $spServer='e285000n2' Goto WinVer EndIf $iparray[3]='10.125.64.0/20' If isiniprange($ipaddress,$iparray) $spServer='e285100n1' Goto WinVer EndIf $iparray[4]='10.125.80.0/20' If isiniprange($ipaddress,$iparray) $spServer='e285000n2' Goto Winver EndIf $iparray[5]='10.125.96.0/20' If isiniprange($ipaddress,$iparray) $spServer='e285250n1' Goto Winver EndIf $iparray[6]='10.125.112.0/20' If isiniprange($ipaddress,$iparray) $spServer='e285270n1' Goto WinVer EndIf $iparray[7]='10.125.128.0/20' If isiniprange($ipaddress,$iparray) $spServer='e285320n1' Goto WinVer EndIf $iparray[8]='10.125.144.0/20' If isiniprange($ipaddress,$iparray) $spServer='e2853400n1' Goto WinVer EndIf $iparray[9]='10.125.176.0/20' If isiniprange($ipaddress,$iparray) $spServer='e285340n1' Goto WinVer EndIf
:WinVer
;****************************************************** ;* Run only if workstation is running an NT based OS * ;* and see if system is at latest Service Pack * ;******************************************************
If @INWIN=1 SELECT CASE @ProductType='Windows 2000 Professional' IF @CSD = 'Service Pack 4' RETURN ENDIF CASE @ProductType='Windows XP Professional' If @CSD = 'Service Pack 1' RETURN EndIf EndSelect
;********************************************************* ;* Check system to see if user has deferred service pack * ;*********************************************************
$CheckUpdate=ReadValue('HKLM\SOFTWARE\JohnsonCounty\SP', 'UPDATE2') $Defer=0
;************************************ ;* Check system for available space * ;************************************
$FreeSpace = DiskSpace(,1) IF $FreeSpace < 250 $SpaceAlert="Low" ELSE $SpaceAlert="Sufficient" EndIf
;***************************** ;* Windows 2000 SP 4 Install * ;*****************************
Select Case @PRODUCTTYPE='Windows 2000 Professional' $spPath='SP\W2KSP4\i386' IF @CSD <> 'Service Pack 4' IF $CheckUpdate <> 1 $SPAlert = MESSAGEBOX($FirstAlert,"Service Pack Update Required", 4116, 60) IF $SPAlert=6 ELSE $MarkReg=WriteValue('HKLM\SOFTWARE\JohnsonCounty\SP', 'UPDATE2', '1', 'REG_SZ') $Defer=1 ENDIF ENDIF IF $Defer=1 or $SpaceAlert="Low" $WR='Deferred or Space Low' GOSUB 'SPLOG' RETURN ENDIF $WR='SP Ran' $SPAlert = MESSAGEBOX($SecondAlert, "Service Pack Update Required", 64, 60) CLS Shell '%comspec% /c \\'+$spServer+'\sp\deploy_sp.exe' ELSE IF $Defer=1 or $SpaceAlert="Low" $WR='Too slow and Deferred or Space Low' GOSUB 'SPLOG' RETURN ENDIF $WR='Copy too slow. Will not run' EndIf
;*************************** ;* XP Service Pack Install * ;***************************
Case @PRODUCTTYPE='Windows XP Professional' $spPath='SP\XPSP1a\i386' If @CSD <> 'Service Pack 1' IF $CheckUpdate <> 1 $SPAlert = MESSAGEBOX($FirstAlert,"Service Pack Update Required", 4116, 60) IF $SPAlert=6 ELSE $MarkReg=WriteValue('HKLM\SOFTWARE\JohnsonCounty\SP', 'UPDATE2', '1', 'REG_SZ') $Defer=1 ENDIF ENDIF IF $Defer=1 or $SpaceAlert="Low" $WR='Deferred or Space Low' GOSUB 'SPLOG' RETURN ENDIF $WR='SP Ran' $SPAlert = MESSAGEBOX($SecondAlert, "Service Pack Update Required", 64, 60) CLS ? 'Please wait.... The Service Pack Update is being silently installed' ? 'Your system will automatically restart once the update has completed.' SHELL '%comspec% /c \\'+$spServer+'\'+$spPath+'\sp\deploy_sp.exe' ELSE IF $Defer=1 or $SpaceAlert="Low" $WR='Too slow and Deferred or Space Low' GOSUB 'SPLOG' RETURN ENDIF $WR='Copy too slow. Will not run' ENDIF Case 1 RETURN ENDSELECT ELSE $Defer='Not Admin' $WR='Not Admin' $LA='Not Admin' $TimeLapse='Not Admin No Copy' GOSUB 'SPLOG' RETURN ENDIF
;******************************* ;* ServicePackUpdate() LOGGING * ;*******************************
:SPLOG If Exist ('\\'+$LogServer+'\LOGS$\SP\'+@WKSTA+'.LOG') Del ('\\'+$LogServer+'\LOGS$\SP\'+@WKSTA+'.LOG') ENDIF If Open(1,'\\'+$LogServer+'\LOGS$\SP\'+@WKSTA+'.LOG', 5)= 0 $log=@DATE+'*'+@TIME+'*'+@USERID+'*'+@FULLNAME+'*'+@lserver+'*'+$IP+'*'+@WKSTA+'*' $log=$log+@ProductType+'*'+@CSD+'*'+$UserDomain+'*'+$LA+'*'+$SpaceAlert+'*'+$FreeSpace+'*' $log=$log+$spServer+'*'+$TimeLapse+'*'+$WR+'*'+$Defer+@CRLF $Out = WriteLine(1, $log) $CloseFile = CLOSE(1) ENDIF RETURN EndFunction
;******************************** ;* Function to check disc space * ;********************************
Function diskspace(optional $drive, optional $format) $format=val($format) $format=iif($format=1,1024,iif($format=2,1024.0*1024,iif($format=3,1024.0*1024*1024,1))) if not $drive $drive='%WINDIR%' endif $diskspace=cdbl(GETDISKSPACE($drive))/$format exit @ERROR endfunction [ 15. August 2003, 15:53: Message edited by: cholbrook ]
|