I was wondering if there was a way to change the priority of a command, and move it up from just a command within the application, to perhaps a system command. The thing is, I’m trying to have the ability to relaunch my application. However, when I first tell the application to quit, and then to launch, it never gets launched because the process is terminated. How can I make the command a general command, and not just one for the application. Thanks.
Have you considered writing a small script or secondary application that could be launched to handle the relaunching of your main app? Hopefully there’s a more graceful way of doing this, but something like the following might work.
Main app (“MainApp”)…
on clicked theObject
if name of theObject is "Relaunch" then
activate application "RelaunchApp"
quit
end if
end clicked
Secondary app (“RelaunchApp”)…
on launched theObject
activate application "MainApp"
quit
end launched
This code is example code only. I wrote it out of my head and did not test it, so it may or may not work in real life.
Good luck…
j
Actually, that sounds like a pretty good idea, and sounds like it should probably work.
One thing is, you could set that second helper application to have an “LSUIElement” value of “1” in its Info.plist, so that it would run as an invisible background application. That way, it wouldn’t ever appear in the Dock, and then disappear after it would quit. So, to the user, it just seems like your application, quit, then started back up.
Hope this helps…
You can try this one:
set shScript to "sleep 2; open " & quoted form of POSIX path of (path to me)
do shell script "echo " & quoted form of shScript & " > /tmp/l" --> store in temp file
do shell script "chmod 755 /tmp/l; /tmp/l > /dev/null 2>&1 &" --> execute it "ignoring responses", and quit
quit