Two questions.

1. Does this have to be run in a login script? That, is can you run it from a system start up script instead? It doesn't seem to be dependent on the user's HIVE.

2. If you do have to run it in a login script, suggest you make use of Glenn's excellent strategy of:
a. Detect there is a problem in the login script.
b. Write to a server share to denote the problem.
c. Have a script running on the server, read the new file on the server share and fix the problem.

Regards,

Brad