Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Turn on and off Internet Sharing

Hi

I'm new in Applescript and want to write script which turn on and off my Internet Connection sharing. So I wrote something like this:

tell application "System Preferences" to set current pane to pane "com.apple.preferences.sharing"
tell application "System Events" to tell process "System Preferences"
if value of checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing" is 0 then
click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing"
else
if value of checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing" is 1 then
click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing"
delay 1
tell application "System Preferences" to quit
end if
end if
end tell

Turn off Connection Sharing works fine - it's start System Preferences, turn off Conncection Sharing and quit System Preferences.

But if I try to turn on Connection Sharing there is window appear with message something like (I have Polish OS X so forgive me inaccurate translation): Are you sure want to turn on internet connection sharing. with 2 buttons: Run (Start) and Cancel.

And now... How to write further part of my script which click Run (start) button and quit System Preferences panel?

Thanks for any advices

Message was edited by: fascik

MacBook, Mac OS X (10.5.6)

Posted on Jan 30, 2009 5:19 AM

Reply
2 replies

Feb 1, 2009 4:06 AM in response to fascik

Hi,

There is a topics on this matter on the last realease of "LEOPARD Security_Config_2ndEd.pdf"

http://images.apple.com/server/macosx/docs/LeopardSecurity_Config_2ndEd.pdf

You can use this shell code in Applescript to turn off the file sharing.


# Disable File Sharing services.
# -------------------------
# Disable FTP.
launctl unload -w /System/Library/LaunchDaemons/ftp.plist
# Disable SMB.
defaults delete /Library/Preferences/SystemConfiguration/ \
com.apple.smb.server EnabledServices
launctl unload -w /System/Library/LaunchDaemons/nmbd.plist
launctl unload -w /System/Library/LaunchDaemons/smbd.plist
# Disable AFP.
launctl unload -w /System/Library/LaunchDaemons/ \
com.apple.AppleFileServer.plist

Hope it helps...

hdr

Turn on and off Internet Sharing

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.