07-21-2021 09:43 AM - edited 07-21-2021 09:45 AM
So for the M1 machines I am trying to initiate a GUI update and while it works if i manually accept the Terminal permissions prompt, it wont work in the script.
Here is what is known.
guiSOFTWAREupdate() {
launchctl asuser ${currentUSERid} /usr/bin/osascript <<EOD
tell application "System Preferences"
activate
tell application "System Events"
tell process "System Preferences"
set frontmost to true
end tell
end tell
if exists window "Software Update" then
tell window "Software Update" to if it is miniaturized then set miniaturized to false
else
set the current pane to pane id "com.apple.preferences.softwareupdate"
end if
tell application "System Events"
tell process "System Preferences"
repeat until (exists window "Software Update" of application process "System Preferences" of application "System Events")
delay 1
end repeat
if (exists static text "Checking for updates…" of group 1 of window "Software Update" of application process "System Preferences" of application "System Events") then
repeat
set itExists to exists busy indicator 1 of group 1 of window "Software Update" of application process "System Preferences" of application "System Events"
if itExists then
delay 1
else
exit repeat
end if
end repeat
end if
if (exists button "Restart Now" of group 1 of window "Software Update" of application process "System Preferences" of application "System Events") then
click button "Restart Now" of group 1 of window "Software Update" of application process "System Preferences" of application "System Events"
set myRESULT to "Restart Now"
else if (exists button "Upgrade Now" of group 1 of window "Software Update" of application process "System Preferences" of application "System Events") then
set myRESULT to "Upgrade Now"
else if (exists button "More info…" of group 1 of window "Software Update" of application process "System Preferences" of application "System Events") then
click button "More info…" of group 1 of window "Software Update" of application process "System Preferences" of application "System Events"
if (exists button "Install Now" of sheet 1 of window "Software Update" of application process "System Preferences" of application "System Events") then
click button "Install Now" of sheet 1 of window "Software Update" of application process "System Preferences" of application "System Events"
set myRESULT to "Install Now"
end if
end if
set frontmost to true
return myRESULT
end tell
end tell
end tell
EOD
echo "$?"
}
Looking to see if you guys have any insight to this matter as I am super stumped now ( @mm2270 for visibility)