AppleScript open Application

I have this script here that needs to mount a network folder, verify that it is mounted, and then start the application. When <tell application appName to activate> is outside the <tell application "System Events"> statement, it works. But as it is written below, the application will not open. Additionally, when I replace <appName> with "QuickBooks", the programs opens as it is written below.


Any help would be greatly appreciated.


set hostname to "TestHost"

set shareFolder to "TestShare"

set user to "TestUser"

set pw to "P@ssword"

set appName to "QuickBooks"


try

set networkPath to "/volumes/" & shareFolder

mount volume "smb://" & hostname & "/" & shareFolder as user name user with password pw

end try


tell application "System Events"

if exists folder networkPath then

tell application appName to activate

else

display alert "Unable to find QuickBooks Database."

end if

end tell

Posted on Jan 9, 2022 4:36 PM

Reply

Similar questions

1 reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

AppleScript open Application

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.