I am trying to set up a script that connects to a networked PC. I want it to look for the PC, and if it is not physically connected, to display a dialog after only 8 seconds. For some reason it is not timing out after 8 seconds. Is goes the full 60 seconds before displaying the dialog. Any ideas why?
tell app “Finder”
repeat
if not (exists “myPC”) then
try
with timeout of 8 seconds
mount volume “smb://192.168.1.4”
end timeout
on error
display dialog “Make sure PC is connected, then click OK.” buttons ¬
{“OK”,"Camcel} default button 1
end try
else
exit repeat
end if
end repeat
end tell
This hasn’t been tested and I’m very tired so my logic could be off (and there’s probably a better way of doing this in the first place) but you could try:
Thank you guys for your great ideas. However, in each of the suggestions made the delay time for the finder to display the dialog is still 60 seconds. That is a long time to wait, especially if it is a user that doen’t know about command-“.”.It seems as if the “mount volume” process freezes the script at that point until it has timed out, rather than going ahead with the repeat loop. Any other ideas?