Applescript: Automatically check and remount server volume stopped working

Solution 1:

I managed to solve this problem by 'borrowing' some code from a blog I found.

on idle
    set intnt to do shell script "ping -c 1 192.168.0.10; echo -n"
    set paras to number of paragraphs in intnt
    if paras < 5 then
    else
        set serverIP to "smb://192.168.0.10/Plex"
        set UserAccount to "[USERNAME]"
        set ServerPassword to "[PASSWORD]"
        set serverVolume to UserAccount
        tell application "Finder"
            try
                if disk serverVolume exists then
                else
                    mount volume serverIP as user name UserAccount with password ServerPassword
                end if
            end try
        end tell
    end if
    return 5
end idle

I also found that if you add this code to the end of an app's info.plist file, its icon doesn't appear on the Dock.

Just copy-and-paste these lines before the final /dict entry.

Downside is I have to use Activity Manager or Terminal to kill the app, but it makes for a tidier Dock.

<key>LSUIElement</key>
<true/>