A programmatic method for disabling all sharing services?
Here's a shell script that turns off the services, but I'm working on finding a more direct solution:
#!/bin/sh
osascript << 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
Don't forget you can simply execute your AppleScript at the command-line using the osascript
tool rather than embedding it <<EOF
style within the script as Daniel suggests.
That means you can reuse the script you know already works with a one line shell script:
osascript ChangeSettings.scpt
(assuming ChangeSettings.scpt
is the file in the current working directory containing the AppleScript you mentioned)