hi, list,     I have an uninstaller application , which is used to delete
the files installed; and also i have a file which located in the current
user's directory, like the ~/Library/LaunchAgents/com.****.plist. and how
can i delete this kind of file, i have tried the
AuthorizationExecuteWithPrivileges
API, it seems not workable, do i give a wrong flag value or something else?
here is my code piece, any comments will be appreciated.

AuthorizationRef myAuthorizationRef;

AuthorizationFlags myFlags = kAuthorizationFlagDefaults;

AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment,myFlags,
&myAuthorizationRef);

AuthorizationItem myItems = {kAuthorizationRightExecute, 0, NULL, 0};

AuthorizationRights myRights = {1, &myItems};



myFlags = kAuthorizationFlagDefaults |

              kAuthorizationFlagInteractionAllowed |

              kAuthorizationFlagPreAuthorize |

              kAuthorizationFlagExtendRights;

AuthorizationCopyRights (myAuthorizationRef, &myRights, NULL, myFlags, NULL);


char *fileDir = "~/Library/LaunchAgents/com.hp.printerAgent.plist";

char* args[3];

args[0]= "-Rf";

args[1]= fileDir;

args[2]= NULL;


myFlags = kAuthorizationFlagDefaults;

OSStatus res = AuthorizationExecuteWithPrivileges(myAuthorizationRef,
"/bin/rm",myFlags,args,NULL);

AuthorizationFree(myAuthorizationRef, myFlags);


and the res value is -60032. and by the way, how can i get the current
user's name string? which cocoa API can get it?
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to