software update

Hi

I was wondering if someone might know an Applescript to launch and execute software update as the local Administrator. I am a systems administrator and we have recently set up and configured proxy servers.

Unfortunately i cannot use softwareupdate -i -a because that command doesn’t go through the proxy server and tries to go direct to the firewall and gets refused. For security i don’t want to open any rules in the firewall especially running as root.

I have worked out how to allow the Gui of software update to run once logged on as administrator and when the keychain asks to allow access to the proxy server it doesn’t matter to click deny it goes through anyway.

My problem is that at the moment i have to go to every single machine, log on as Administrator and run the software udate with loads of machines. I would like for the users to have an Applescript as a run only app when they double click it the softwareupdate launches not asking for Administrator authentication.

If anyone has an ideas i would be very grateful.

Is “softwareupdate -i -a” a shell command and can it pass along those passwords when run? If so couldn’t you have a local applescript on the computer do a shell script. You might then be able to set up a rule in your mail application to launch the applescript when it receives a certain message so all you have to do is send a bulk e-mail to all your computers with the subject line “run software update”.

like i said softwareupdate -i -a doesn’t go through the proxy and goes straight to the Firewall. So that will not work i need a script which will launch the software update GUI and ketstroke the Admin cradentials… please

so far i have this

tell application “Finder”
activate

open application file “Software Update.app” of folder
“CoreServices” of folder “Library” of folder “System”
of startup disk

end tell

The problem i have now is to click the install X items and keystroke the username and password

any help would be appreciated.

almost there i need to click the install button but i am unsure how to do this. At the moment with script below i can manually click on the install button then the Admin credentials fills in ok but i still have to click on the OK button manually

tell application “Finder”
activate

open application file “Software Update.app” of folder
“CoreServices” of folder “Library” of folder “System”
of startup disk
delay 60

tell application “System Events” to tell proces “Software Update” to keystroke “Administrator PASSWORD”
end tell

Got it working here it is hope you guys find it useful

–Launches the Finder and opens Software Update.app in System/Library/CoreServices/

tell application “Finder”
activate

open application file "Software Update.app" of folder "CoreServices" of folder "Library" of folder "System" of startup disk
--Delay of 60 seconds to allow software to list
delay 60

end tell

–Tells System Events to to press the return key for the install button

tell application “System Events” to tell window 1 to keystroke return

–Delay of 2 seconds
delay 2

–Tells System Events to Enter the Administrator username and password

tell application “System Events” to tell process “Software Update” to keystroke “Administrator PASSWORD GOES HERE”

–delay 1 second
delay 1

–Tells System Events to press the return key for the OK button

tell application “System Events” to tell window 1 to keystroke return

tell application "Software Update"
	activate
end tell
tell application "System Events"
	tell process "Software Update.app"
delay 60
		keystroke "PASSWORD"
                keystroke return
	end tell
end tell

So i believe this is what you want. Much more simple.

nope doesn’t work. If you try this you just get an error Software Update is not running. You need to say the full path to where the application lies /System/Library/CoreServices

Ok fine it might work if you opened Software Update manuall and Entered the Admin username, tabbed to the password filed then double click on the scripted app to fill in the password but what is the point in that… might as well script the whole lot and would seems a half done script.

hmmm seems like i have a problem with the process Security Agent to click the OK button. At the moment i can’t get this working. This is what i have so far


--Launches the Finder and opens Software Update.app in System/Library/CoreServices/

tell application "Finder"
    activate
   
    open application file "Software Update.app" of folder "CoreServices" of folder "Library" of folder "System" of startup disk
    --Delay of 60 seconds to allow software to list
    delay 60
   
end tell

--Tells System Events to to press the return key for the install button

tell application "System Events" to tell window 1 to keystroke return

--Delay of 2 seconds
delay 2

--Tells System Events to tell the process Security Agent to  Enter the Administrator username

tell application "System Events" to tell process "SecurityAgent" to keystroke "Administrator    PASSWORD GOES HERE"

--delay 2 seconds
delay 2

--Tells System Events to tell  the process Security Agent to press the return key for the OK button

tell application "System Events" to tell process "SecurityAgent" to keystroke return

Interesting… It works up to the point for opening, then it does return…
But i did make an error… the code is suppose to be

tell application "Software Update"
	activate
end tell
tell application "System Events"
	tell process "Software Update.app"
		delay 60
		keystroke return
		keystroke "PASSWORD"
		keystroke return
	end tell
end tell

Also This does work… at least for Leopard Users… It works only if you don’t need to click Agree for the licenses.

Browser: Safari 526.11.2
Operating System: Mac OS X (10.5)

Hi,

it’s never recommended to use uncontrolled delays, the scripts are not reliable.
A better way is to check for certain UI elements like a sheet or a window
try this


activate application "Software Update"
tell application "System Events"
	tell process "Software Update"
		tell window 1
			repeat until exists sheet 1
				delay 1
			end repeat
			repeat while exists sheet 1
				delay 1
			end repeat
			delay 0.5
			click button 1
		end tell
	end tell
	repeat until (exists window "Authenticate" of process "SecurityAgent")
		delay 0.5
	end repeat
	tell window "Authenticate" of process "SecurityAgent"
		tell group 1
			set value of text field 1 to "user"
			set value of text field 2 to "¢¢¢¢"
		end tell
		click button "OK" of group 2
	end tell
end tell

What if your system is up-to-date. Should their be a section in the middle that that tells the script to choose “OK” if you get the pop-up system is up-to=date?

No problem



activate application "Software Update"
tell application "System Events"
	tell process "Software Update"
		tell window 1
			repeat until exists sheet 1
				delay 1
			end repeat
			repeat while exists progress indicator 1 of sheet 1
				delay 1
			end repeat
			delay 0.5
			if exists button "Quit" of sheet 1 then
				click button "Quit" of sheet 1
				return
			else
				click button 1
			end if
		end tell
	end tell
	repeat until (exists window "Authenticate" of process "SecurityAgent")
		delay 0.5
	end repeat
	tell window "Authenticate" of process "SecurityAgent"
		tell group 1
			set value of text field 1 to "user"
			set value of text field 2 to "¢¢¢¢"
		end tell
		click button "OK" of group 2
	end tell
end tell

Thanks Stefan. Solid coding! Works great!

Has anyone made this admin authentication work on 10.6.4?

Model: MacBook Pro
AppleScript: 2.1.2
Browser: Firefox 3.6.9
Operating System: Mac OS X (10.6)

Works like an absolute charm. I had no idea that you could use Applescript to target visual elements. Can’t wait to use this knowledge elsewhere!