title: AppleScript to load a volume mount, start an application, and restart if the mac comes out of suspend.
body: <p>I am having some issues with my Mac connecting to an SMB share on my network, and then loading an application immediately after that.</p>
  
  <p>For the most part, everything works when the mac turns on just by setting the volume to mount on login as usual, and also run the application (XBMC) on login also.</p>
  
  <p>Occasionally though, for no reason that I have been able to pin down after an extensive amount of troubleshooting, the auto mounting of a volume some times fails as it believes the network location is unavailable. As a result the Mac can't create the volume mount unless I restart the Mac, then it works again.</p>
  
  <p>Now I want an AppleScript that will attempt to create the volume mount three(3) times, and then load XBMC. If the volume can't be mounted after 3 attempts, force the Mac to restart. This would then cause the script to run from scratch again after a restart.</p>
  
  <p>How would I achieve this in AppleScript?</p>
  
  <p>Second problem:</p>
  
  <p>I have my Mac set to go to suspend after 1 hour of inactivity. The only problem is that if the Mac has been suspended for some time, upon waking up XBMC can't load remotely stored content some of the time.</p>
  
  <p>So, is it therefore possible to have a script run when the Mac resumes from being suspended, that makes the Mac perform a restart?</p>
  
  <p>Thanks to anyone who has read the entirety of my post, I realise it is a bit of a rant.</p>
  
  <p>Regards.</p>