i have app needs restart dock application. have tried both apple script:
var errordict: nsdictionary? = nil let applescript = nsapplescript(source: "tell application \"dock\" quit") var error = applescript?.executeandreturnerror(&errordict) if let errordict = errordict { println("an error occured: \(errordict)") } ... , nstask:
let task = nstask() task.launchpath = "/usr/bin/killall" task.arguments = ["dock"] task.launch() ... , nstask:
func restartfinder () { let task = nstask() task.launchpath = "/bin/bash" task.arguments = ["killall dock"] task.launch() } however, seems app not allowed restart it. i'd release app appstore, how can restart dock?
error when using apple script:
an error occured: { nsapplescripterrorappname = dock; nsapplescripterrorbriefmessage = "application isn\u2019t running."; nsapplescripterrormessage = "dock got error: application isn\u2019t running."; nsapplescripterrornumber = "-600"; nsapplescripterrorrange = "nsrange: {27, 4}"; } error when using nstask:
killall: warning: kill -term 255: operation not permitted update
have tried stprivilegedtask, didn't work me either. neither did auth window.
i try using applescript, instead this:
var errordict: nsdictionary? = nil let applescript = nsapplescript(source: "do shell script \"killall dock\" administrator " + "privileges") var error = applescript?.executeandreturnerror(&errordict) if let errordict = errordict { println("an error occured: \(errordict)") } this way, executes shell script(as if through terminal) admin privileges. problem since task done system or user, requires type in admin password.
Comments
Post a Comment