BREAK ON
; Variable definition
$sKey_BootStrap="HKLM\foo\bar"
$sVal_BootStrap="BootStrapCode"
$sBootStrapCode='Shell @@SCRIPTEXE+" "+@@SCRIPTDIR+"/"+@@SCRIPTNAME $$PPID=Dispatcher"'
; Write bootstrap code
; Every instance of this script will re-write the bootstrap code.
; This means that when a new version of the script is release the
; bootstrap process will automatically be updated with new code.
$=WriteValue($sKey_BootStrap,$sVal_BootStrap,$sBootStrapCode))
; BOOTSTRAP SECTION START-------------------------------------------
; If this is the boostrap instance of the script
; just keep running the bootstrap code.
If IsDeclared($PPID)=0
While TRUE
$=Execute(ReadValue($sKey_BootStrap,$sVal_BootStrap))
Loop
Exit 0 /* NotReached */
EndIf
; BOOTSTRAP SECTION END---------------------------------------------
;
; Main script.
; If any of the script below is changed the bootstrap process will be unaffected.
If $PPID="Dispatcher"
; This is a primary dispatcher process which will create the workers
Else
; This is a worker process
EndIf
Exit 0