script no longer works if I add it as a login hook

Here is the code of my script which works when I’m logged in (admin) and it also works when I log in as a regular user.
I have placed this script in the /Library/Management folder and used the LoginWindow Manager from Bombich to add it as a login hook.

The problem is when I login it does everything correctly except it says that I don’t have permission to open the folder or the mount. But if you run the script manually after login it works?!?!

Any suggestions would be greatly appreciated.


property user_name : “”
set dialog_1 to display dialog “Please enter your username” default answer “”
set the user_name to the text returned of dialog_1

property pass_word : “”
set dialog_2 to display dialog “Please enter your password” default answer “” with hidden answer
set the pass_word to the text returned of dialog_2

mount volume “smb://” & user_name & “:” & pass_word & “@tys3/students”
on error
display dialog “There was an error during the mount process. The share did not mount.”

end try

set folder_to_alias to “STUDENTS:” & user_name as alias
tell application “Finder” to make new alias file at desktop to folder_to_alias

Model: powerbook g4
AppleScript: 2.1.1 (81)
Browser: Safari 523.12.9
Operating System: Mac OS X (10.4)