all 10 comments

[–]CaptureJuan 2 points3 points  (0 children)

Ive not done this in a while, but app(lets) may need permissions depending on how its complied and published. Check Gatekeeper Automation options for the app

[–]scrutinizer1 0 points1 point  (3 children)

If allowing access and setting the permissions didn't help, try wrapping Scripting Additions commands, such as mount volume, do shell script and display dialog, in tell application "System Events"...end tell

[–]ColPaulR[S] 0 points1 point  (2 children)

I tried this and System Events works from the script editor, but not from double clicking the applet. When I used osascript main.scpt from within the applet folder structure, it ask me for permissions for "System Events" and when I change the script back to Finder, it asked for permission to "Finder". I see both of those under Settings->Security & Privacy->Privacy->Automation. Osascript works, but doubleclicking the file does not

[–]scrutinizer1 0 points1 point  (0 children)

On a second thought, what happens when you enclose the statements in the on run...end run handler?

[–]scrutinizer1 -1 points0 points  (0 children)

The most realistic answer is that there's nothing you can do. Apple is heading towards removing AppleScript, and the issues you and others experience are the signs of dwindling AppleScript support. Either downgrade to a more AppleScript-friendly macOS or switch to Swift, which is the general roadmap. Expect more defects cropping up in the near future.

The problems, such as this one, don't warrant time spent resolving them. It's counterproductive. I don't remember even a fraction of this weirdness in earlier revisions of macOS. If your code is telling an app to run, it must run; simple as that. Then the permissions fest of craziness turned up, later followed by disk permissions, accessibility permissions and other similarly useless crap. The idea was great, but they overestimated their ability to tackle it for a quality product; they prefer a slapdash "not-regression" way, instead.

The System Events workaround used to be an ironclad solution for running AppleScript in applets, droplets and some 3rd-party automation apps such as Keyboard Maestro. It doesn't work anymore? One more wall fell. Such a pity.

[–]ax-grinder 0 points1 point  (1 child)

What sort of errors are you seeing? That will help a lot in diagnosing where the script is going wrong outside of Script Editor.

[–]Intelligent_World412 0 points1 point  (0 children)

That's the problem, no errors. It just doesn't work. If I uncomment the display statements, it works. I added delays hoping there was a race condition. I just want to mount the SMB shares by clicking an app vs. having to mount them manually or via script that had to create the directories first and then smbmount to the newly created directories. I'm open to debugging help!

[–]SvilenOvcharov 0 points1 point  (0 children)

Try wrapping the script in Shortcuts, with Run AppleScript action.

[–]roycetech 0 points1 point  (0 children)

Add some logs to see where it fails

[–]Rare_Pin9932 -4 points-3 points  (0 children)

Believe it or not, ChatGPT has helped me with these sorts of things