Hi why this dont launch any applications when its not running?
set apps to {"Safari", "TextEdit"}
repeat with myCount from 1 to the (count of the apps)
tell application "Finder"
if (name of (every application process)) does not contain item myCount in apps then
set runThis to item myCount in apps
tell application runThis
try
run -- apps can't receive the run event except at startup, from the Finder, so this causes an error
on error -- when an error happens, do nothing!
end try
end tell
end if
end tell
end repeat
your ‘tell app runthis’ is within a ‘tell app “Finder”’ statement. This would work:
set apps to {"Safari", "TextEdit"}
repeat with myCount from 1 to the (count of the apps)
tell application "Finder"
set allApps to (name of every application process)
end tell
if allApps does not contain item myCount in apps then
set runThis to item myCount in apps
tell application runThis
try
run -- apps can't receive the run event except at startup, from the Finder, so this causes an error
on error -- when an error happens, do nothing!
end try
end tell
end if
end repeat
Maybe I didn’t understand exactly what you wanted to do - but it seems quite complicated for this task and could be reduced to this in my opinion:
set apps to {application "Safari", application "TextEdit"}
tell application "Finder" to launch (every item of apps)