Your app does start the process and then quits itself straight away leaving the process running.
You could try and check in the Automator action to see if the process is running. if it is quit it, if it is not launch it.
isRunning=`ps aux | grep -i "Textedit.app"| grep -v grep`
if [ $isRunning -eq "" ]; then
echo "is Not Running"
/abspath/to/my-command
else
echo "is Running"
# terminate code here
fi;
So when you click the App in the Dock. to will either start the process or stop it.
Disclaimer: I do not own Borderlands 2 and so I cannot predict what the results of this process will be. Your safest bet is to go the Mac App Store page for Borderlands 2 and use the Borderlands 2 Support link. All Mac App Store apps are required to have a ‘support’ link, although some are more useful than others. The one for Borderlands 2 looks like it will lead to actual, official support, so I suggest you try that first.
That being said, the following is the troubleshooting technique that I use when trying to figure out why a Mac App Store app won’t launch.
Use at your own risk, etc. Remember that I’m just some guy on the Internet (allegedly!) giving you free, un-guaranteed advice. I almost always have a complete, recent, fully bootable backup on my Mac just in case something goes wrong. So should you, especially before mucking around with stuff.
1) Quit The App
We’re going to be moving the app’s preferences file, and you don’t want to do that when it is running. That would be a bad idea.
2) Use the Finder:
- Use the Go → Go to Folder menu item
- Enter ~/Library/Containers/ as shown here:
Click “Go” (or press Enter) and you will see all of the various “Containers” used on your Mac.
n.b.: Tread carefully. Apple hides the ~/Library/ folder because mucking around in there can cause problems.
This is what mine looks like:
Yours will look different but similar. Hopefully you will be able to tell which one goes to the you are trying to fix.
I am going to use com.multimarkdown.composer.mac (MultiMarkdown Composer 2) just because it’s easier to work with a specific example.
Find the “Saved Application State” folder for the app which will not open.
You will find it inside the app’s “Container” folder (above) → Data → Library → Saved Application State
Inside that folder will be one more, which ends with “.savedState” and contains the information used to restore the windows which were open when you quit the app.
Move that folder to the Desktop, or even the Trash if you want. Then re-launch the misbehaving app.
If it still won’t launch I’d repeat the process but instead look inside the ”Preferences” folder instead of ”Saved Application State” and I’d look for the file which doesn’t look like a link or an alias (in this case, com.multimarkdown.composer.mac.plist
) and I would copy that file to the Desktop or the Trash, understanding that I was effectively deleting all of my saved preferences. Then re-launch the misbehaving app.
If that didn’t work, well, then I’d probably do something desperate like move the app’s entire folder from ~/Library/Containers/ (such as ~/Library/Containers/com.multimarkdown.composer.mac/
) to the Desktop or the Trash and try one last time.
After that I might even delete the app and download it again from the Mac App Store.
(If you need to see any of the images in a larger size you can find them all at http://media.tjluoma.com/askdifferent/116501/.)
Best Answer
You should be able to do this using AppleScript, saving the script you create as an application, then dragging it to the dock.
For example, if you start the Apple Script Editor (
/Applications/Utilities/Apple Script Editor.app
). Then type something like the following, replacing my trivial example of/bin/date
with the command you want to runor
Either script should work, but the first explicitly opens the Terminal - it just depends on the application you want to run and whether it sticks around.
Then save this script as an application (use the dropdown in the save dialog to change the "File Format" to "Application").
You should then be able to drag the .app file you created to the Dock and run it.