croezen -
Recommend checking the share permissions - can 'Everyone' access the share, or only members of specific group(s)? Also, does problem exist for all users, specific users on specific workstations, or all users on specific workstations?

I am guessing that a function executed later in your script is providing some security setting/access for the user(s) in question. On first execution of the script the user does not have rights to the share, but on the 2nd manual execution the rights are now in place - defined by completion of login script during first execution. So, I also suggest you check the latter part of the script for anything that might help with this possibility.

Bill