0
我正在使用MAC應用程序,在該應用程序中,我想刪除以前由我的應用程序安裝的幫助程序工具。對於MAC應用程序運行沒有授權彈出框的ShellScript
我使用STPrivilegedTask來運行我的ShellScript。 這是我用來實現此目的的代碼。
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"
現在,上面的代碼工作完美,但它要求用戶的授權彈出。
我想在沒有此授權彈出窗口的情況下運行此腳本。
我已經在另一個問題中搜索,但他們都沒有爲我工作,這就是爲什麼我創建了這個問題。