Warning, Spoiler:
 Code:
RedirectOutput("c:\~")
Will create file C:\~
0 is written to the file because you do not catch the return value, per example:
$ReturnValue = RedirectOutput("c:\~")

 Code:
RedirectOutput("c:\~:~")While 1
Redirects the code but I do not know where you are redirecting to
IMHO "c:\~:~" is an invalid file specification.
But As far as I can see, RedirectOutput() does not return an error.

 Code:
While 1
	@SID
Loop
Endless loop.
Because you do not catch the Return Value of "@SID", the output is redirected to "C:\~:~". But as I said, I do not know where that is.
I think the user will be logged of from his computer when the script is broken because I see no
Break On
or similar at top of the script