I have a MAC OSX cocoa application,where i used NSAppleScript to run some script with administrator privileges .The application works fine when it is launched manually or from any other script .
But NSAppleScript doesn't launch the intended script when i tried to launch the application from package maker .
I have made a postflight script to launch the application from package maker .
Postflight:
#!/bin/sh
open pathOFApp
NSAppleScript usage:
NSDictionary *error = [NSDictionary new];
NSAppleScript *appleScript = [[NSAppleScript new] initWithSource:@"do shell script \"pathOFScript \" with administrator privileges"];
if ([appleScript executeAndReturnError:&error]) {
NSLog(@"-----success --------");
}
else{
NSLog(@"-------Failure-----");
}
Please help to fix this .
I don't know the answer with applescript/PackageMaker, but have you tried using the unix security tool to launch your executable? I think it's been available since 10.5. You can probably combine this and your executable in one statement too.
/usr/bin/security execute-with-privileges /path/to/executable