0

I wrote a simple script to have an Active Directory user install a specific keychain required for network access. I've used it successfully on 10.7-10.9 and the instruction prompts came up fine.

When 10.10 came around, the "activate" command didn't bring the program to the front anymore. Instead, after Keychain Access came up, the AppleScript icon would just bounce like crazy on the dock.

Here's the code:

activate
display dialog "Welcome to the Mac Network Cerificate Installer (Version 6.0)" & return & return & "Click Okay to start installation of the Mac Network Certificate. Please wait until the next dialog box shows up." with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:Bonjour.icns" buttons {"Okay"} default button 1 with title "WONK"

delay 2

activate application "Keychain Access"

tell application "Finder" to open POSIX file "/Files/bn-virtualcar.crt"

delay 2

activate
display dialog "In the Keychain Access prompts, click the 'Add' then 'Always Trust'." & return & return & "After you have entered your password, close Keychain Access by clicking 'Keychain Access' in the top left corner and selecting Quit." with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:Bonjour.icns" buttons {"Okay"} default button 1 with title "WONK"

delay 2

tell application "System Events" to delete login item "Mac-Network-Cert"

There's a similar question at How to ensure Applescript dialog focus in OS X 10.10 (Yosemite)?, but it doesn't work for me since these aren't password prompts or shell scripts. I just want two instructions boxes to show up.

Any help would be appreciated.

Community
  • 1
  • 1
ghostof101
  • 187
  • 1
  • 9
  • Just a little note: I've tried changing "activate" to "tell me to activate" and it didn't work. – ghostof101 Jan 27 '15 at 20:39
  • Sounds a bit of a hokey approach - aside from opportunites for error, encouraging users to install random bits of software is not the safest habit to cultivate. IANASysAdmin, but if it's a company network, couldn't/shouldn't you be pushing certs out via ARD? You could try Apple's ARD forum, e.g. here's a previous discussion: https://discussions.apple.com/thread/2343380. `certtool` in particular looks like something you should look into. – foo Jan 28 '15 at 00:18
  • You're right, it is a hokey approach. But at the moment, my hands are tied by the nature of the certificate I'm forced to use. Until the certificate gets fixed and updated on my IT group's end (I'm a different division), there's nothing I can do. – ghostof101 Feb 11 '15 at 00:47

1 Answers1

2

Your dialogs should look like this, to ensure focus, or stick them into the Finder tell block.

tell application "SystemUIServer"
    activate
    display dialog "Welcome to the Mac Network Cerificate Installer (Version 6.0)" & return & return & "Click Okay to start installation of the Mac Network Certificate. Please wait until the next dialog box shows up." with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:Bonjour.icns" buttons {"Okay"} default button 1 with title "WONK"
end tell

delay 2

activate application "Keychain Access"

tell application "Finder" to open POSIX file "/Files/bn-virtualcar.crt"

delay 2
tell application "SystemUIServer"

    activate
    display dialog "In the Keychain Access prompts, click the 'Add' then 'Always Trust'." & return & return & "After you have entered your password, close Keychain Access by clicking 'Keychain Access' in the top left corner and selecting Quit." with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:Bonjour.icns" buttons {"Okay"} default button 1 with title "WONK"
end tell
delay 2

tell application "System Events" to delete login item "Mac-Network-Cert"
McUsr
  • 1,400
  • 13
  • 10
  • Thank you. While I'm still working on getting this certificate to work on the system.keychain level, this is a wonderful workaround to get it into the login.keychain. – ghostof101 Feb 11 '15 at 00:50