I've never seen an environment where the login script is copied from a file share to a local system. That's pretty fragile in itself. Login scripts are designed to be robust because they are delivered directly from a specific share on the DC - the specific DC that authenticated the user - so there's never a situation where it can't run. (well, it CAN fail if there are NO domain controllers available, but you won't be authenticated, either.) The DLL file generally isn't required, especially if it isn't being registered.
Size doesn't matter - we have Kix (not logon, though) well over 10-15,000 lines.
The O/S detect logic seems OK, actually, although LOOKS strange. It's looking for the current O/S to NOT be XP or W7. If the O/S was either of those, the match would not be zero, and the Exit would not execute. If you're running anything later than Windows 7 (8.x, 10, 11), the script will terminate right there. I would comment out that section.
The versioning logic only defines the $HKLMImageNo variable. You can search the remaining script to determine if/how that variable is used. Setting it to non-zero may work if this value is no longer being defined in the registry. Since MapDrives.kix is loaded via CALL, you must review that script as well for this variable use.
From a developer's perspective, this adds a significant amount of environmental complexity to what should be a relatively simple process.
I own a software dev company and Kix is a specialty. Would be happy to provide private assistance to troubleshoot if you don't want to post publicly. We sign NDA's with clients all the time to preserve confidential information. PM me if interested in this.
We actually have a "no-code" Kix-based login script that has a ton of features and runs quickly. We were able to reduce login script times from 1.5 minutes to 6-seconds for one large client with over 50 resource mapping references, with over 450 department-specific mappings. You can even map resources by AD attribute, like "Manager=Tom".
_________________________
Actually I
am a Rocket Scientist!