"do shell script \"echo command\" with administrator privileges"
However, I got error as below:
NSAppleScriptErrorNumber = "-2147450879";
But it works fine on my friend‘s mac, anybody know how to solve this problem.
I have the same problem here on two different computers:
I am trying to launch a script from my application and it fails with NSAppleScriptErrorNumber = "-2147450879".
This happens with macOS Catalina on an Intel Mac Mini and Monterey on M1 Mac Mini. Other machines here do not have that problem. It also happed to some of our customers.
When creating a new admin user, it runs without an error when using that account. But that is not a solution for me and especially not an option that would help our customers. I need to get it running on the main account as well.
What was interesting: After creating the second Admin accound and restarting the Catalina Mac, it worked on both Admin accounts. But on the first account, the error came up again after the next restart.
Could you shed some more light on what might be causing this error, and what settings, permissions etc. I could check to find out what is different between these two Admin accounts?
Could you shed some more light on what might be causing this error … ?
Not really. If the code works fine on one account and fails on another, it’s likely that the code is correct and that the problem lies in the account setup. I’ve never investigated that in depth because configuration issues like this fall outside of DTS’s purview.
Last I checked OSA continues to Component Manager for this sort of thing, so you could write Component Manager code to dump the component list to see if this problem is reflected there. For example, on my Mac the code below prints:
0x10001 ' aso' 'rcsa'
0x10000 ' aso' 'rcsj'
0x10003 ' aso' 'tpcs'
All the OSType
values are byte reversed (because I’m on a little-endian machine and I was too lazy to write the big swapping code) so this should be:
0x10001 'osa ' 'ascr' AppleScript
0x10000 'osa ' 'jscr' JavaScript
0x10003 'osa ' 'scpt' Generic Scripting System
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
#include <Carbon/Carbon.h>
int main(int argc, char **argv) {
#pragma unused(argc)
#pragma unused(argv)
Component cursor = NULL;
ComponentDescription query = { .componentType = kOSAComponentType };
Handle name = NewHandle(0);
do {
cursor = FindNextComponent(cursor, &query);
if (cursor == NULL) {
break;
}
ComponentDescription desc = {};
OSStatus err = GetComponentInfo(cursor, &desc, name, NULL, NULL);
if (err != noErr) {
printf("%p -\n", cursor);
} else {
printf("%p '%4.4s' '%4.4s' %.*s\n",
cursor,
(const char *) &desc.componentType,
(const char *) &desc.componentSubType,
(int) name[0][0], // Length byte of Pascal string.
name[0] + 1 // First byte of string contents.
);
}
} while (true);
return EXIT_SUCCESS;
}
Same problem here. I'm just trying to call a menu item in another app.
Testing on Monterey 12.3.1.
Running NSAppleScript::executeAndReturnError.
I've set NSAppleEventsUsageDescription.
I've got the entitlement com.apple.security.automation.apple-events.
I've also got com.apple.security.temporary-exception.apple-events for the target app.
I'm successfully notarised and installer is stapled.
This thread is enlightening but I still can't run an AppleScript. https://stackoverflow.com/questions/70548909/how-to-run-applescript-from-c-in-macos-sandbox-environment-without-entitlement
For the record: This problem has gone away under Ventura. Same app, same installer, same entitlements... and the applescripts run just fine on Ventura. So I'm guessing it became a known issue and nobody wanted to fix it on Monterey.