#76270 - 2003-08-07 07:46 PM
Emergency Patch Distribution System Example
|
Sealeopard
KiX Master
   
Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
|
The following script demonstrates a way to distribute a patch to all computers inside a domain from a central location. Ideally, the script would run as a scheduled task under domain administrative privileges at night. The patch would be provided with command-line arguments that automatically install the patch and reboot the system. Optionally, a list of computers, e.g. servers, can be excluded for the patch distribution
This example will only open notepad and load a potentially existing file and is for demonstration purposes only.
Requires the updated ScheduleTask v1.3 UDF
code:
; uses the COMNetView() and ScheduleTask() v1.3 UDFs
break on dim $iRC
; set restrictive script settings $iRC=SETOPTION('Explicit','on') $iRC=SETOPTION('NoVarsInStrings','on') $iRC=SETOPTION('WrapAtEOL','on')
dim $asComputers, $sComp, $sExcluded dim $sTSName,$sTSDate,$sTSTime,$sTSType,$sTSCmd,$sTSPrms
; do not run the scheduled command on these computers $sExcluded='server1','server2','server3','server4'
$asComputers=COMNetView() if ubound($asComputers)+1 ? 'Computers in domain '+@DOMAIN+' = '+(ubound($asComputers)+1) else ? 'Error '+@ERROR+' - '+@SERROR ? 'Unable to retrieve list of computers in domain '+@DOMAIN endif
$sTSName='example.job' $sTSDate='TODAY' $sTSTime='NOW' $sTSType='ONCE' $sTSCmd='notepad' $sTSPrms='%TEMP%\test.txt'
for each $sComp in $asComputers if ascan($sExcluded,$scomp)=-1 ? 'Scheduling task for '+$sComp $iRC=scheduletask($sTSName,$sComp,$sTSDate,$sTSTime,$sTSType,$sTSCmd,$sTSprms) ? 'Error '+@ERROR+' - '+@SERROR else ? $sComp+' excluded from update' endif next
exit 0
[ 07. August 2003, 20:37: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.
|
|
Top
|
|
|
|
#76271 - 2003-08-07 08:12 PM
Re: Emergency Patch Distribution System Example
|
Richie19Rich77
Seasoned Scripter
   
Registered: 2002-08-16
Posts: 624
Loc: London, England
|
Doh, I didn't download JT.EXE.
But now I have it working, first time I have used JT and the Scheldue UDF.
Looks good.
Thanks [ 07. August 2003, 20:36: Message edited by: Richard Farthing ]
|
|
Top
|
|
|
|
#76276 - 2003-08-08 12:44 AM
Re: Emergency Patch Distribution System Example
|
Richie19Rich77
Seasoned Scripter
   
Registered: 2002-08-16
Posts: 624
Loc: London, England
|
Jens to get RunNow (/RJ) to work I have added this into the UDF just before it shells out to '$Shellcmd' for the final time.
code:
If $Time = 'Now' $shellcmd = $shellcmd+ ' /RJ' EndIf
What is the point of having a time of "now" when it will actually run 60 seconds in the future, so I have said that if Time = Now, then Run job Now (/RJ).
Works for me, might be something worth thinking about, not saying that you should change the UDF, but it is up to you.
One other thing, when this is running on a remote PC, it is hidden, but the "$shellcmd = $shellcmd+ ' Hidden=0'" is set to 0, any ideas.
It is running in the background, but not being displayed on screen, not a problem as I wouldn't want the user to see what is being installed, but just wanted to know if it can be displayed on screen.
Thanks [ 08. August 2003, 10:47: Message edited by: Richard Farthing ]
|
|
Top
|
|
|
|
#76280 - 2003-08-08 10:54 PM
Re: Emergency Patch Distribution System Example
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11629
Loc: CA
|
I don't disagree that there are not otherways around it.
Just wanted to point out that one should not just blindly perform this task. I would really hope that any large network would already have an Admin on board that knows this.... but hey! you never can tell.
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 675 anonymous users online.
|
|
|