I would like to the run the following command from my Cocoa project. (hides the spotlight icon)
sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search
I have found two ways how to call the command and get the following output
1) Using NSTask
NSTask *writeTask = [[NSTask alloc] init];
[writeTask setLaunchPath:@"/bin/chmod"];
[writeTask setArguments: @[@"755",@"/System/Library/CoreServices/Search.bundle/Contents/MacOS/Search"]];
[writeTask launch];
>>chmod: Unable to change file mode on /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search: Operation not permitted
2) Pipes
NSString *command = @"sudo chmod 755/System/Library/CoreServices/Search.bundle/Contents/MacOS/Search";
fp = popen([command UTF8String], "r");
>>sudo: no tty present and no askpass program specified
I have not found a way how to run any of these in super user mode. How can I prompt the user to enter his password and eventually run this command with the required privileges?