Given that there is a file called copystuff in the Resources folder in the xCode project, and this file reads:
#!/bin/sh
cp -R /Users/someuser/Documents /Users/admin/Desktop
And if this bit of code below is associated with a button in IB ... it will copy the directory / Users / someuser / Documents to / Users / admin when the button is clicked in the Cocoa application ... It works when the application is launched in the account admin (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 for NSTask to execute a script running as root, and this code is called from an account without an administrator? Or asked differently. Is it possible to code Objective-C to run scripts from say / usr / bin as root from an account without an administrator?