Novice: script to prevent app launch?


I’m looking for help with a problem I’ve been working on:

I want to write a script which will:

prevent a specific application from launching while the script is running
run continuously (loop)
be invisible in the dock
be invisible in the finder
be launchable via remote access

Now maybe there’s already a product out there which will do this, but I’m not aware of it.

I’d use the capability of Remote Access to send a terminal command to accomplish this, but I’m not sure how that could be done without knowing the process id.

Any help in finding a solution would be really appreciated.

Not sure how you’d do everything you want with an applescript but I think the following bash script does what you want. It will kill all instances of the application every second. If it’s an application that for some reason ignores kill you could use kill -9 but you probably don’t want to if you can avoid it. Just put it in a text file, and use “chmod 700 filename” then “./filename” if you’re trying to stop any user from running the application you will have to use root.

If you want to run it remotely it will quit when you logout, if you don’t want it to quit you should look up the command screen.

while [ 1 ]
# replace “application” and “name” with a each word in the
# application’s name. Where $11 is the first word, $12 the second
# etc.

pids=`ps -auxcww | awk '{if ($11=="application" && $12=="name") print $2}'`
# example:
# pids=`ps -auxcww | awk '{if ($11=="DashboardClient") print $2}'`

for pid in $pids
kill "$pid"
sleep 1


Thanks a bunch, Eldrard.

I must confess that I don’t know how to execute this script.

I did edit it as instructed, save it as a text file (named “nicescript” ) and the chmod 700

Then, in the terminal I attempted to run it with


It returned

“while: bad interpreter: No such file or directory”

Any thoughts?

Try replacing the first line with one of the following:

Also there were a couple of typoes in the version of the script I posted which I have fixed. Make sure in the one you have that there are the same number of {s as there are }, and that you use == not = after the if.

All you would have to do to keep the app from running is this:

tell application "System Events"
if some_application is in name of processes then
		tell application some_application
		end tell
end tell
end repeat 

you’d want an on idle statement in there instead of a repeat, but either way it would be visable in the dock and finder.

to make an app’s icon not appear on your dock when it runs,

edit the Info.plist file inside the Contents directory inside the .app file.

before the “” tag, add:


save changes, and then from the terminal put in:
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -f (Path to your application)