Applescript Network Drives Issue
We are mainly a Windows based business, but we are adding MAC's for our design users and a few user in development. I'm having an issues with Apple-script adding network drives without an error. Below is the basic script I am using to add the drives and I have them run as an application every time a user logs in. Thing is it will randomly work and then randomly not work a few minutes later if the machine is rebooted or logged off of. I have ran the script in Apple-Script and the error comes up maybe half the time. If I use the application script I saved from Apple-Script the same thing will happen. Hit or miss. I don't get why it would work one moment and not the next. It always comes back with a "AppleEvent handler failed finder got an error (-10000)" if it doesn't work or at times "expected end of line, etc. but found identifier." The drives will be added like I want them to, but the windows and the error will stay on the screen when they should close out. This happens with all users who have this setup and the file are created and saved under their user names because at first I was getting errors saying the user couldn't access the file. Normally I would deal with it, but the users love to complain they need to exit windows on login. If I hit the edit button on the error it will highlight the "close every window" section of the text. If I close out and reopen the same file it may run just fine no errors or may not work with the same error. Is there a better way to close out of all the finder windows using script to stop this from happening? Any help would be appreciated. Thanks.
Saved as an application and runs on login per user (each has a different application file):
tell application "Finder"
open location "smb://server/folder$"
delay 1
open location "smb://server/folder"
delay 1
(ADD MORE NETWORK LOCATIONS IF NEEDED)
end tell
delay 3
tell application "Finder" (also tried: tell application "finder" to close every window)
close every window
end tell
MacBook Air, OS X Yosemite (10.10.3)