Sometimes works, sometimes doesn’t:
osascript -e 'tell application "System Events" to tell application process "Software Update"
click button "Agree" of window 1
end tell'
Is there a more reliable way? All the computers are doing the exact same update, one third to half will take the command just fine, the other two thirds to half will just give me a NSReceiverEvaluationScriptError: 4 (1).
Trying to automate a few things through Remote Desktop and osascript. For example, Adobe still does not release their patches as dmgs. Annoys the hell out of the Applied Art & Design department, as we have to log in to every computer, run the patch, click agreement buttons and type in passwords for 80 some-odd computers, as opposed to simply applying the patch via Remote Desktop with a convenient dmg. sigh
Much obliged,
-Rob
The error almost certainly means that you’re clicking while window 1 is not the one you want (because it hasn’t appeared yet). You should test for that specific window by name and then click. Use a repeat loop that exits when the window appears or after some time if it doesn’t and then clicks or informs you of the timeout.
Vis-a-vis Adobe, have you considered just making your own .dmg of a fully upgraded copy of the app and replacing the version on each machine with yours, or is it that Adobe insists on ‘phoning home’ before upgrading every copy? I don’t recall and can’t test.
Try using a “delay” in the script. Sometimes you can sent clicks and keystrokes via events faster than the OS can update a window with the new buttons.
I found “delay 0.3” or “delay 0.5” to be the smallest useful delay for times when UI scripting needs it. I’ve found liberally sprinkling delays in a UI script then slowly taking them out allows me to fine-tune them. Also using a variable for the delay value can be handy.
Hello
Here is a script which seems to do the trick.
Caution: a password is asked when the button is clicked.
tell application "Software Update"
activate
end tell
tell application "System Events"
tell application process "Software Update"
repeat
if enabled of (get properties of button 1 of window 1) is true then exit repeat
delay 0.5
end repeat
click button 1 of window 1
end tell
end tell
Yvan KOENIG (from FRANCE vendredi 6 octobre 2006 20:52:33)
Worked like a charm. Thanks Yvoa.
-Rob