Wondering if there's a way to get rid of an error in Apple Script to mount server I was wondering if anyone could help me with this. Sorry for the noob question. I recently created a script to automatically mount a Time Machine image in a hard drive connected to my router. For the most part, the script works great. It attaches the drive when I turn on the computer and, if it disconnects for any reason, it reconnects and mounts the image again. Here's the script:

on idle
set mySSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'"
set mountedDiskName to "Time Machine"
set diskIsMounted to false
if mySSID is "TALKTALK844E28" or mySSID is "TALKTALK844E285G" then
    tell application "System Events" to set diskNames to name of every disk
    if mountedDiskName is in diskNames then
        set diskIsMounted to true
    end if
    if mountedDiskName is not in diskNames then
        set diskIsMounted to false
    end if
    if diskIsMounted is false then
        mount volume "smb://192.168.1.1/"
        delay 30
        do shell script "hdiutil attach -mountpoint '/Volumes/Time Machine' /Volumes/Guille/TimeMachine.sparsebundle"
    end if
    if diskIsMounted is true then
    end if
end if
return 300
end idle


However, every once in a while, I get this error:


It doesn't really bother me because if I just click on OK it goes away and tries again 5 minutes later. However, I would like to know if there's a way to make sure these dialogs are automatically dismissed so they don't interrupt my workflow and Time Machine stays unobtrusively in the background until I accidentally send something to the trash :-)
I'm really only a beginner to scripting, but I'm wondering why you have so much code in your script.  I was able to accomplish the exact same results with using only a couple of commands.  

mount volume "smb://192.168.2.66/"
do shell script "hdiutil attach -noverify '/Volumes/Data_Smokestack_ATC/James’s MacBook Pro.sparsebundle'"


I have both of my Airport Time Capsules set with static IPv4 addresses, so their IP’s never change (so I always know how to connect to them if I need to)

The do shell script part of my code waits until the mount volume command completes, therefore, I did not need to insert a delay command. On my system using the latest version of macOS Sierra,  if I run this code again while the volume is already mounted, this script just quietly completes with no errors or messages.  

That said, my thought is wouldn't it just be more “code efficient” to run these two lines of code inside of a repeat loop at 15 minute intervals for 12 or 24 hours or something like that? Then to be saved as a stay open application?