Resolved Disable networks when opening a certain app?

Discussion in 'Mac Programming' started by keysofanxiety, Oct 28, 2015.

  1. keysofanxiety macrumors 604

    keysofanxiety

    Joined:
    Nov 23, 2011
    #1
    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!
     
  2. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #2
    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...
     
  3. keysofanxiety thread starter macrumors 604

    keysofanxiety

    Joined:
    Nov 23, 2011
    #3
    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.
     
  4. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #4
    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.
     
  5. keysofanxiety thread starter macrumors 604

    keysofanxiety

    Joined:
    Nov 23, 2011
    #5
    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. :)
     
  6. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #6
    You're very welcome. Just bear in mind that it's pretty easy for a user to circumvent.
     
  7. chrfr macrumors 603

    Joined:
    Jul 11, 2009
    #7
    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.
     
  8. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #8
    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.
     
  9. moonman239 macrumors 68000

    Joined:
    Mar 27, 2009
    #9
    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.
     

Share This Page