i’ve got this script that is designed to see if a network drive has been mounted, if not, it attempts to mount it, and if it can’t, it gives the user the option to try again, work offline, or quit.
The way I’ve written it, it seems to me that if it can’t mount the drive, but the user clicks on “Try Again” each time it fails, then this script should run forever, or until it successfully mounts the drive. However, currently, this script will only repeat once if you click “Try Again.”
After you click try again the second time, the script ends and I’m not exactly sure why.
Hopefully someone here can help me get a better understanding of what the script is doing!
Thanks
Joel
global theButton
mountDrive("User", "drowssap")
on mountDrive(u, p)
tell application "Finder"
with timeout of 60 seconds
if exists disk "Drive" then
return
else
try
with timeout of 20 seconds
mount volume "afp://192.168.1.1:548/user" as user name u with password p
end timeout
on error
tell application "Finder"
activate
end tell
display dialog "The server could not be found. Would you like to work offline?." buttons {"Yes", "Stop", "Try Again"} default button 1 with title "Could Not Locate Server" with icon 1
set theButton to the button returned of the result
end try
end if
end timeout
end tell
end mountDrive
if theButton is equal to "Yes" then
return
else
if theButton is equal to "Stop" then
myError("User Cancelled Script") of me
else
if theButton is equal to "Try Again" then
mountPSC("User", "drowssap")
end if
end if
end if
on myError(theError)
tell application "Finder"
activate
display dialog theError buttons {"Ok"} default button 1 with icon 1 with title "Script Cancelled"
end tell
end myError
Model: Macbook
AppleScript: 2.2.1
Browser: Firefox 3.0.5
Operating System: Mac OS X (10.5)