A programmatic method for disabling all sharing services? I'm seeking a programmatic method for disabling all the sharing services on a Mac. My preference is for an AppleScript or a shell script.

I'd like to have the services shown in the picture below disabled when I execute the script. The solution should be compatible with Alfred, Keyboard Maestro or any other global productivity tool.

The services I'd like to disable are:



I could come up with the following with some googling:

File sharing (on/off)

do shell script "/usr/sbin/AppleFileServer" password "x" with administrator privileges
do shell script "/usr/bin/killall AppleFileServer" password "x" with administrator privileges


Internet Sharing (on/off)

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist        


(I would prefer terminal commands or batch scripts to apple scripts. Here's an apple script solution for those interested.)
Here's a shell script that turns off the services, but I'm working on finding a more direct solution:

#!/bin/sh
osascript &lt;&lt; HERE
tell application "System Preferences" to activate
tell application "System Events" to tell process "System Preferences"
    click menu item "Sharing" of menu "View" of menu bar 1
    delay 2
    tell window "Sharing" to repeat with x from 1 to 11
        if value of checkbox 1 of row x of table 1 of scroll area 1 of group 1 is 1 then click checkbox 1 of row x of table 1 of scroll area 1 of group 1
    end repeat
end tell
tell application "System Preferences" to quit
HERE