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.)
sudo shutdown -h now
will disable the services, but it will have other effects as well.