As written, the following script displays a dialog stating “The File Can’t be Found”. I want to eliminate the commented-out code and to have openApplicationAtURL return some value indicating whether the app was launched. Is this possible? Thanks!
use framework "AppKit"
use framework "Foundation"
use scripting additions
set theWorkspace to current application's NSWorkspace's sharedWorkspace()
set theApp to current application's |NSURL|'s fileURLWithPath:"/Does/Not/Exist.app"
-- set fileExists to theApp's checkResourceIsReachableAndReturnError:(missing value)
-- if fileExists is false then
-- display alert "An error has occurred" message "The app could not be found"
-- return
-- end if
set startOptions to current application's NSWorkspaceOpenConfiguration's configuration()
theWorkspace's openApplicationAtURL:theApp configuration:startOptions completionHandler:(missing value)
BTW, I’ve considered the launchApplication and launchApplicationAtURL methods. They return a value indicating if the app was launched as I want, but they are deprecated.