relaunch hidden one-liner...

I need to relaunch my app in hidden state but am kinda stuck

I use this scriplet from jj to relaunch:

: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

It works great, however, I can’t get it to start as hidden. I may have to go with a routine to hide the app itself upon restart but I prefer to get the hidden argument in the above script. Is there any way?

It might be that being the frontmost app disables hiding (I am not aware of your idea why to use shell scripting)
Maybe applescript’s “launch” instead of “activate” accomplishes what you want

E.g.


tell application "TextEdit" to launch
tell application "System Events" to set visible of application process "TextEdit" to false