And another comment: CleanDirectory accepts arrays as inputs, thus only one call is needed if the directories and the file filters are passed as arrays. Thus
code:
$dirs[0]=$MyTemp
$dirs[1]='C:\TEMP'
$dirs[2]=$SystemTemp
$rc=cleandirectory($dirs,'*.*',7)
$rc=cleandirectory('%SystemRoot%','*.tmp',7)

would work, too.
_________________________
There are two types of vessels, submarines and targets.