Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

keysofanxiety

macrumors G3
Original poster
Nov 23, 2011
9,539
25,302
Hi all,

I'm completely new to any sort of programming but luckily I'm looking to do something fairly specific, so I was hoping there might be a way to do it through Automator or Terminal or something.

Simple as this: when opening a specific app in the Applications folder, I either want a warning telling the user to disconnect from all networks and they can't proceed with opening the app until they click 'OK'. Otherwise if there's a way to automatically disconnect from all networks when opening that app, that would be fine as well.

Any ideas on what could be done? Is this fairly simple? :)

Thank you for any advice you can give me!
 
Sounds like a bit of a messy one to me. I guess the obvious thing to ask is why you need to drop the network before a particular app is launched?

Do the users always launch the app by clicking it's icon in the Applications folder? If so, then maybe you could be sneaky and hide it away somewhere (some app's don't like that, some won't mind...).

Then write a short applescript that *looks* like the original app (e.g. change it's icon). But in fact it displays your dialog, then launches the *real* app.

It's not a very robust solution, I admit and there are several ways that a user could find to circumvent it*, either accidentally or on purpose. But in it's favour, it's simple to implement.

Failing that, I think you're going to get into some fairly nasty hacks.

Good luck!




* e.g. by finding your hidden app, opening a document that is opened by the hidden app, or selecting "Keep in Dock" and launching the app from there etc...
 
Sounds like a bit of a messy one to me.

Do the users always launch the app by clicking it's icon in the Applications folder? If so, then maybe you could be sneaky and hide it away somewhere (some app's don't like that, some won't mind...).

Then write a short applescript that *looks* like the original app (e.g. change it's icon). But in fact it displays your dialog, then launches the *real* app.

It's not a very robust solution, I admit and there are several ways that a user could find to circumvent it. But in it's favour, it's simple to implement.

Failing that, I think you're going to get into some fairly nasty hacks.

Hi there Superscape, I really appreciate your response!

It would just be an app launched from the shortcut in the Dock. It's just on one computer and mainly for internal usage, predominantly to remind the user to disconnect from all networks before running the app, so even a dialogue box that pops up which they have to OK to before the app launches would suffice. It was mainly a quick query to see if there's an easy way to do that - it's not the end of the world if it can't be done, but worth asking I suppose! :)

Thanks again Superscape, please let me know if you've got any ideas.
 
It would just be an app launched from the shortcut in the Dock.

OK. Then if you chose to implement the method I described above then you could save an AppleScript app with the following code (I'm imagining you're using iTunes):

Code:
display alert "Please disconnect from networks" message "Please disconnect from any networks. When you've done that, hit the OK button and iTunes will launch."

tell application "iTunes"
    launch
end tell

You can copy iTunes' icon and paste it onto your app so it *looks* like iTunes. Call your AppleScript app something like "iTunes Launcher". Remove the real iTunes from the dock and replace it with a link to your new app.

Ta-dah!

r.
 
  • Like
Reactions: keysofanxiety
OK. Then if you chose to implement the method I described above then you could save an AppleScript app with the following code (I'm imagining you're using iTunes):

Code:
display alert "Please disconnect from networks" message "Please disconnect from any networks. When you've done that, hit the OK button and iTunes will launch."

tell application "iTunes"
    launch
end tell

You can copy iTunes' icon and paste it onto your app so it *looks* like iTunes. Call your AppleScript app something like "iTunes Launcher". Remove the real iTunes from the dock and replace it with a link to your new app.

Ta-dah!

r.

I wish I can 'like' this 1000 times. Thank you so so much. Your instructions were clear and concise. This is exactly what I needed. I tested it out and it works perfectly. Icon makes it look great as well.

Once again, thank you SO much for taking the time to assist me. I really do appreciate it. :)
 
I wish I can 'like' this 1000 times. Thank you so so much. Your instructions were clear and concise. This is exactly what I needed. I tested it out and it works perfectly. Icon makes it look great as well.

Once again, thank you SO much for taking the time to assist me. I really do appreciate it. :)
A better, and more difficult means to circumvent is to install something like Little Snitch, and block network access for that application. You can set this up so that non-admin users cannot disable the network rule that blocks it, but allows everything else.
 
A better, and more difficult means to circumvent is to install something like Little Snitch, and block network access for that application. You can set this up so that non-admin users cannot disable the network rule that blocks it, but allows everything else.

Agreed. That's definitely a better solution to just prevent network access for the app in question. Although it's unclear as to whether that's the goal, or whether its necessary to disconnect from the network entirely.
 
Option B is for the system admin to put the apps in a place where they are accessible only to specific user accounts; your app's task will then be to run the applications under one of those accounts after the network check.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.