Objective c 在没有授权的情况下运行MAC应用程序的ShellScript弹出窗口

Objective c 在没有授权的情况下运行MAC应用程序的ShellScript弹出窗口,objective-c,macos,shell,root,privileges,Objective C,Macos,Shell,Root,Privileges,我正在MAC应用程序上工作,我想删除我的应用程序以前安装的帮助工具 我正在使用运行我的shell脚本。 下面是我用来实现这一点的代码 NSString *pathForUninstallFile = [[NSBundle mainBundle] pathForResource:@"Uninstall" ofType:@"sh"]; STPrivilegedTask *taskToRemoveHelperTool = [STPrivilegedTask launchedPrivilegedTask

我正在MAC应用程序上工作,我想删除我的应用程序以前安装的帮助工具

我正在使用运行我的shell脚本。 下面是我用来实现这一点的代码

NSString *pathForUninstallFile = [[NSBundle mainBundle] pathForResource:@"Uninstall" ofType:@"sh"];
STPrivilegedTask *taskToRemoveHelperTool = [STPrivilegedTask launchedPrivilegedTaskWithLaunchPath:pathForUninstallFile arguments:[NSArray arrayWithObjects:@"Uninstall.sh", nil]];
这是我的shell脚本Unistall.sh

launchctl unload /Library/LaunchDaemons/com.bsecure.HelperTool.plist
rm /Library/LaunchDaemons/com.appleCompany.HelperTool.plist
rm /Library/PrivilegedHelperTools/com.appleCompany.HelperTool

security -q authorizationdb remove "com.appleCompany.readLicenseKey"
security -q authorizationdb remove "com.appleCompany.newMethod"
现在,上述代码工作正常,但它会询问用户的授权弹出窗口。

我想在没有此授权弹出窗口的情况下运行此脚本。


我已经搜索了另一个问题,但没有一个问题适合我,这就是我创建此问题的原因。

那么您希望在不提示用户输入密码的情况下以升级权限运行任务吗?如果是这样的话,你就不走运了,这是办不到的