Given that there is a file called copystuff in the Resources folder in a an xCode project, and that file reads:
#!/bin/sh
cp -R /Users/someuser/Documents /Users/admin/Desktop
And if this bit of code below is linked to a button in IB ... it will copy the /Users/someuser/Documents directory to /Users/admin when the button is pressed in a Cocoa app... It works when app is launched in an admin account ( using OS X 10.5.x here) ...
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/bin/sh"];
[task setArguments:[NSArray arrayWithObjects:[[NSBundle mainBundle]
pathForResource:@"copystuff" ofType:@"sh"], nil]];
[task launch];
My question is.. is there a way to have NSTask run a script running as root while this code is called from a non-admin account? Or asked another way..can Objective-C be coded to run scripts from say /usr/bin as root from a non-admin account?