You might want to "soften-up" that reference to the users profile:

$sub="C:\documents and settings\@userid"

Maybe like:

$sub="%userprofile%"

cause simply appending the userid is not bullet-proof.