Page 1 of 1

Force Quit an App with Hazel/AppleScript/Shell Script

PostPosted: Thu Feb 16, 2012 2:14 pm
by restfulsilence
Hello everybody,

I have a Mac at home which runs TeamViewer. Sometimes the program crashes but doesn't close.
I would need to Force Quit it, but as the program itself is the remote program to control my second Mac, I can not force quit it. I would like to use Hazel and Dropbox to do so.

In my dropbox folder I have a random file with a random name. But if I change the name to i.e. "QuitTeamViewer" Hazel should run a script which Force Quit the App TeamViewer.

I got some help and actually this script should do the trick:

do shell script "killall TeamViewer"

So I made the rule with AppleScript like:

If there is a file with the name "QuitTeamViewer" - run AppleScript with code 'do shell script "killall TeamViewer"'

But it doesn't work.

Does anybody has an idea. I have not worked properly with AppleScript nor Shell Scripts, so I don't even know if I embeded it correctly.

Thank you in advance.

Re: Force Quit an App with Hazel/AppleScript/Shell Script

PostPosted: Thu Feb 16, 2012 2:36 pm
by Mr_Noodle
First off, if all you are doing is running a shell script, no need to wrap an AppleScript around it. Just do a shell script with the stuff in quotes.

Not sure why it isn't working. Try entering that command in Terminal and see if that works. Also, check Hazel's logs to see if there was any error running the script.

Re: Force Quit an App with Hazel/AppleScript/Shell Script

PostPosted: Thu Feb 16, 2012 11:01 pm
by restfulsilence
No it is working. The little thing which caused an error was:

killall -KILL TeamViewer

instead of

killall TeamViewer

Thanks anyway! :)