objective-cmacosapplescriptcore-servicesremote-management

how to programmatically enable remote management under sharing in Mac OS X 10.8


I am working on a project which requires VNC Server to be run on my system (Mac OS X v10.8).

VNS server is installed in my Mac system, now I need to run VNC server, but for running the server sufficient privileges needs to be provided programmatically or using Apple Script(System Preference -> Sharing -> Remote Management -> Enable the check box).

How could I enable remote management through objective c program or apple script ? or is there any API provided by Apple to manage sharing options?


Solution

  • You can enable and configure the remote management service with the kickstart command. It's not in the usual PATH, so you need to specify its full path:

    /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart
    

    Its option format is a little cryptic, but with some experimentation you should be able to get the effect you want (see Apple's KB #HT2370 and SS64.com's "man page").

    Also, it must run as root, so from AppleScript, use do shell script with administrator privileges. I think you'll need something close to this:

    do shell script "/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -restart -agent -privs -all" with administrator privileges