Put cookie1 twice.

Golden rule, if you call other kix scripts, your MUST ensure they will 'Exit' properly at the end of each script to get back to your main logon script.

Use 'if @error=...' a lot to detect errors like failed drive mappings and reg reading so your logon script never stops before it gets to the cookie1 instructions