Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.3: Start Internet Sharing via AppleScript Internet
I had previously submitted an AppleScript that started up Internet Sharing on a Mac, as it is will not remain on after restarts. The need remains in Panther, but the AppleScript needs to be different. I don't know if the UI Scripting Beta is still necessary, because I upgraded without a clean install. See the previous hint for more information about getting this script to work.

A pane was added to Panther verifying that you want to share your connection. This new script gets past that pane. Here is the new script:
tell application "System Preferences"
  activate
end tell

tell application "System Events"
  tell process "System Preferences"
    click menu item "Sharing" of menu "View" of menu bar 1
    delay 10
    tell window "Sharing"
      if (exists tab group 1) then
      tell tab group 1
        click radio button "Internet"
        delay 1
        click button "Start"
        delay 1
      end tell
      end if
      if exists sheet 1 then
        tell sheet 1
          click button "Start"
        end tell
      end if
    end tell
  end tell
end tell

ignoring application responses
  tell application "System Preferences" to quit
end ignoring
Cut and paste the above into Script Editor. If you then save it as an application and set it in your startup items, you won't have to worry about doing it manually.
    •    
  • Currently 2.43 / 5
  You rated: 2 / 5 (7 votes cast)
 
[15,947 views]  

10.3: Start Internet Sharing via AppleScript | 12 comments | Create New Account
Click here to return to the '10.3: Start Internet Sharing via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.3: Start Internet Sharing via AppleScript
Authored by: eevyl on Oct 27, '03 03:12:16AM

I think yesterday my Sawtooth remembered this setting after a restart, without the need of this script. Using Mac OS X 10.3 after a fresh install... I will double check but I think it is fixed in Panther.



[ Reply to This | # ]
10.3: Start Internet Sharing via AppleScript
Authored by: pmag on Oct 27, '03 07:00:17AM

Yes, fortunately, Panther now remembers if you started Internet Sharing and turns it on after a restart. Good job, Apple.



[ Reply to This | # ]
10.3: Start Internet Sharing via AppleScript
Authored by: thefinite on Oct 27, '03 01:00:56PM

Yeah, I submitted this hint before I discovered that Panther saves the setting after restarts. I sent a follow-up hint just a few minutes after this one saying something to that effect, but I see that this slipped through the cracks anyway. Oh well. People will figure it out.

---
--Boom Shanka



[ Reply to This | # ]
10.3: Start Internet Sharing via AppleScript
Authored by: madamov on Nov 28, '03 03:37:24AM

Yes, Panther keeps this after restart, but on my machine it goes of while machine is running randomly. Once in few days I have to start it again.



[ Reply to This | # ]
10.3: Start Internet Sharing via AppleScript
Authored by: polarbear on Oct 27, '03 10:36:33PM

With 10.3, internet sharing configured by an alternate GUI eg, IPNetShareX also remains on after restarting. A bonus for those of us sharing "built-in ethernet" (only one NIC).



[ Reply to This | # ]
10.3: Start Internet Sharing via AppleScript
Authored by: seann on Nov 27, '03 12:23:53PM

so anyone get a way to turn systemevents on without going into the System Preferences?



[ Reply to This | # ]
I get and AppleScript error
Authored by: BrunoUsesBBEdit on Jun 27, '04 12:07:41AM
System Events got an error:
NSReceiverEvaluationScriptError: 4
this happens on the line:
click menu item "Sharing" of menu "View" of menu bar 1

---

--==>==--

[ Reply to This | # ]

I get and AppleScript error
Authored by: descoff on Sep 12, '04 01:23:02PM

You need to click on 'Enable access for assistive devices' in the Pref Pane 'Universal Access' to allow UI Scripting in applescript.



[ Reply to This | # ]
I get and AppleScript error
Authored by: Jewtobog on May 10, '08 11:15:06PM

Try this:

tell application "System Preferences" to set current pane to pane "com.apple.preferences.sharing"
tell application "System Events" to tell process "System Preferences"
click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing"
delay 1
if (exists sheet 1 of window "Sharing") then
click button "Start" of sheet 1 of window "Sharing"
end if
end tell
ignoring application responses
tell application "System Preferences" to quit
end ignoring



[ Reply to This | # ]
10.3: Start Internet Sharing via AppleScript
Authored by: Jewtobog on May 10, '08 11:39:26PM

Posted this to an error (above) but it gets buried so posting it again at top level for someone hunting for this script and will get stumped by the original one. If your looking for a script to do this [on & off] try this:

tell application "System Preferences" to set current pane to pane "com.apple.preferences.sharing"
tell application "System Events" to tell process "System Preferences"
click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing"
delay 1
if (exists sheet 1 of window "Sharing") then
click button "Start" of sheet 1 of window "Sharing"
end if
end tell
ignoring application responses
tell application "System Preferences" to quit
end ignoring



[ Reply to This | # ]
10.3: Start Internet Sharing via AppleScript
Authored by: prramesh on Nov 11, '09 08:18:25AM

In snow leopard you have to change row 10 into row 11



[ Reply to This | # ]
10.3: Start Internet Sharing via AppleScript
Authored by: prramesh on Nov 11, '09 08:19:35AM

in snow leopard you have change row 10 into row 11



[ Reply to This | # ]