Thanks for the replies. I’ve done something similar to these in the past - my main script has a packager script that creates a firstRun file within the script bundle when I create a final version of a build, that is deleted after the initial setup() routine that runs if that file is there when the script is run by the user. That process requires a separate script though, that I don’t have for smaller scripts.
I had wondered if there was a way to patch in to whatever OSX uses to know to check in the first place, but I should know by now that is asking for too much.
All of these suggestions are great, and broke me of the one angle I was looking at this, so I appreciate it!
Shane, I really do like the approach of using the version number, though. That allows the setup() code to run for each new version, as I do now. It would also allow the various permission triggers to fire off only on the first run of each version, if I choose not to code sign.
For that matter, is all of this even necessary? I am using the following code at the beginning of the script to trigger security dialogs all at once:
tell application "Finder" to count windows
tell application "System Events" to count windows
tell application "Safari" to count windows
Is there any significant runtime consequence in doing that EVERY time the script is run? If not I can just forego the whole firstRun construct and count windows even when it is not necessary. Or for that matter, would counting windows be faster than looking for the defaults info? Am I gaining anything by trying to only count windows on the first run?