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.