Take your original code and put
 Code:
Del 'c:\temp\log.txt'
$RC = RedirectOutput('c:\temp\log.txt')

in the beginning of the file and try. You can even wrap that in an if statement so it only redirects when you pass an argument (or vice-versa).

Put
 Code:
$RC = RedirectOutput('')

at the end to close the output file.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D