scrippitng support - block imessage

Malcolm
Contributor II

So I found a means to block imessage, beyond application blocking, which doesn't work if the student reproduced the application as another name.

What I found is if oyu set the folder ~/library/messsages to read only to the end user the application wont launch.

What I am hopping to do is to invoke a script which I can launch at target times, which will close messages, and also set the application folder to read only, during school hours.

So essentially there will be two scripts...

One will be launchable from self-service which will repair the permissions only for outside of hours, and the other is an automatic one which will run on login up until 3:15pm and at 8:30am automatically.

Just need help with the script coding, I'm more competent with apple script rather than bash.

4 REPLIES 4

mm2270
Legendary Contributor III
which doesn't work if the student reproduced the application as another name.

The problem right there is that you're using the full application name, probably including the .app at the end. Drop that and simply use the "Messages" process name and it will work no matter how many times they copy the app and rename it.

Malcolm
Contributor II

@mm2270 all the student needs to do is duplicate the app and rename it to something random, and it will continue to function.

Swift
New Contributor II

Might be other ways... but one solution might be to use AppWarden, and modify the 'AppWarden-WillLaunch' script to look something like this:

#!/bin/bash
sv_ThisAppBundleIdentifier="$(echo ${1} | cut -d":" -f3)"
if [ "${sv_ThisAppBundleIdentifier}" = "com.apple.iChat" ]
then
  sv_ThisAppProcessID="$(echo ${1} | cut -d":" -f6)"
  kill ${sv_ThisAppProcessID}
fi

mm2270
Legendary Contributor III

@Malcolm I don't think you understand what I was saying. If you use the full application name for the restriction, like Messages.app then yes, naming it something random gets around the restriction, because it can no longer see Messages.app but will instead see Foo.app or whatever it was renamed to.

This isn't the case however, if you use just Messages and check the "Restrict Exact Process Name" checkbox in the Restricted Software entry. This is because buried within the Messages.app is a "Messages" binary, in the path /Applications/Messages.app/Contents/MacOS/Messages This is actually the program that runs when it's launched. The end user cannot rename that or the app won't run at all, and Restricted Software will pick up the process name if you set it up as I outlined above, and close it down.