Hi all,
Having a really strange problem on this one… The attached script I’ve written installs the software application fine on 10.5 through to 10.7 but when it comes to launching the application I get an error saying the application cannot be found despite it sitting there in the Applications folder. If I copy out the tell application “softwareApplication” to activate, onto a new script, it’ll work fine!
I’ve tried reverse engineering the script but still not put my finger upon the issue.
Any help appreciated.
Cheers
Will
-- Variable to check the version of OS X
set osVersion to do shell script "sw_vers -productVersion"
if osVersion begins with "10.5" then
set staticText to 1
else if osVersion begins with "10.6" then
set staticText to 1
else if osVersion begins with "10.7" then
set staticText to 6
end if
-- Variable for Package Tree testing
set BetaPackage to "Software"
property softwareApplicationWindow : "Install softwareApplication"
-- Varibale for location of the .dmg
set softwareApplicationPath to POSIX path of (path to desktop) & "Packages/" & BetaPackage & "/softwareApplication/installer/softwareApplication.dmg"
-- 2 second delay variable
set delayPeriod to 2
-- Variables for keystroke commands
set rightArrow to ASCII character 29
set upArrow to ASCII character 30
set downArrow to ASCII character 31
set tabKey to ASCII character 9
set returnKey to ASCII character 13
-- Mount the .dmg if not already mounted
tell application "Finder"
if not (exists "softwareApplication") then
do shell script "hdiutil attach " & quoted form of softwareApplicationPath
end if
end tell
-- Tell the Shell to execute the package (.pkg/.mpkg)
do shell script "open '/Volumes/softwareApplication/softwareApplication.pkg'"
delay delayPeriod
-- Click Continue on Welcome window
my waitForTextAndClickButton("Welcome", "Continue", staticText)
delay delayPeriod
-- This handles the destination selection that sometimes appears
tell application "System Events"
tell process "Installer"
tell window softwareApplicationWindow
repeat until value of static text staticText begins with "Standard Install"
if value of static text staticText begins with "Select a Destination" then
click button "Continue"
end if
end repeat
delay 2
end tell
end tell
end tell
-- Click Install on installation window
my waitForTextAndClickButton("Standard Install", "Install", staticText)
delay delayPeriod
-- Press Enter on authentication popup
tell application "System Events"
tell process "Installer"
keystroke (ASCII character of 13)
end tell
end tell
delay delayPeriod
-- Click Close to complete install
tell application "System Events"
tell process "Installer"
tell window softwareApplicationWindow
repeat until value of static text staticText begins with "Installation completed" or value of static text staticText begins with "The installation was"
delay 0.1
end repeat
delay delayPeriod
click button "Close"
end tell
end tell
end tell
delay delayPeriod
-- Unmount .dmg and create shortcut on Desktop
tell application "Finder"
do shell script "hdiutil detach '/Volumes/softwareApplication'"
delay (delayPeriod + 1)
make new alias to file "softwareApplication.app" of folder "softwareApplication" of folder "Applications" of startup disk
delay delayPeriod
end tell
delay delayPeriod * 3
-- Launch softwareApplication
tell application "softwareApplication" to activate
-- Function handling loop looking for static text to exist before clicking button
on waitForTextAndClickButton(theText, theButton, staticText)
tell application "System Events"
tell process "Installer"
tell window softwareApplicationWindow
repeat until value of static text staticText begins with theText
delay 0.1
end repeat
delay 2
click button theButton
end tell
end tell
end tell
end waitForTextAndClickButton