#76379 - 2003-08-15 12:12 AM
Service Pack Deployment
|
Anonymous
Anonymous
Unregistered
|
I'm currently trying Doc's service pack script, however I work with multiple subnets in our schools. What I'm trying to do is get the script to look at the ip address and then use the appropriate sp server, since I have 9 buildings linked by T1. Any suggestions would be greatly appreciated. Right now the messagebox displays nothing which would tell me if I used this in my script it would fail.
Call "isiniprange.udf"
ServicePack
Function ServicePack() Dim $ip,$ipaddress,$iparray,$spServer
$ipaddress=@IPADDRESS0
Call "isiniprange.udf"
ServicePack
Function ServicePack() Dim $iparray[1],$ipaddress,$iparray,$spServer
$ipaddress=@IPADDRESS0
Select $iparray[0]='10.125.16.0/20' Case isiniprange($ipaddress,$iparray) $spServer='jcboe' $iparray[1]='10.125.32.0/20' Case isiniprange($ipaddress,$iparray) $spServer='alt' EndSelect MessageBox($spServer, "Service Pack Update Required", 64, 60)
[ 15. August 2003, 00:13: Message edited by: cholbrook ]
|
|
Top
|
|
|
|
#76381 - 2003-08-15 03:16 AM
Re: Service Pack Deployment
|
Anonymous
Anonymous
Unregistered
|
I appologize for the odd post, for some reason when I ran the postprep on the script it duplicated everything. I think I may have the problem figured out. I will attempt to repost the code except without the double post.
|
|
Top
|
|
|
|
#76383 - 2003-08-15 03:51 PM
Re: Service Pack Deployment
|
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 ]
|
|
Top
|
|
|
|
#76385 - 2003-08-15 06:56 PM
Re: Service Pack Deployment
|
Anonymous
Anonymous
Unregistered
|
I've just done a simple test using your suggested code and it will return nothing as to what the $spserver is. I'm using a simple text message box to see what it returns and I just get a blank box. What am I doing wrong? I'm still a newbie at using kixtart. I appologize if my coding seems a little strange. Below is the simple code that I'm trying to use.
Call "isiniprange.udf"
$ipaddress = @IPADDRESS0
Select Case isiniprange($ipaddress,'10.125.16.0/20') $spserver='jcboe' Case isiniprange($ipaddress,'10.125.32.0/20') $spserver='alt' EndSelect
$SPAlert = MessageBox($spserver, "Simple Test", 64, 60)
|
|
Top
|
|
|
|
#76387 - 2003-08-15 07:24 PM
Re: Service Pack Deployment
|
Anonymous
Anonymous
Unregistered
|
I just tried the code you suggested, it's doing something now. It returns no match. However it is not returning the jcboe that it should since my machines ip is 10.125.17.1 which would put it in the range of 10.125.16.1 - 10.125.31.254. I'm currently running version 4.21 of kix. I really appreciate your help.
|
|
Top
|
|
|
|
#76390 - 2003-08-18 08:12 PM
Re: Service Pack Deployment
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
What!! Updated the UDF today and no PostPrep used
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|