What is the value of @ERROR after the failed USE?

And have you tried running the script after logon, in a command prompt?

Kind regards,

Ruud