Imported from the Apple Support Forums via the Wayback Machine 🔗
What you can do is run "scselect" in Terminal. This will give you a unique ID for each of your networks. The following script is one that can be used for two networks named "Airport #1" and "Ethernet #1":
tell application "System Events" tell network preferences get the name of current location as text set a to the result end tell end tell tell application "Finder" activate display dialog "You are using network " & a with icon 1 display dialog "Do you want to change networks?" with icon 1 buttons {"Airport #1", "Ethernet #1", "No"} default button 3 set userChoice to button returned of the result if userChoice is "Airport #1" then do shell script "/usr/sbin/networksetup -setairportpower airport on" delay 2.5 do shell script "scselect XXX12345-111X-4E68-AA35-CA6D04D5A2BF" <<example string<< else if userChoice is "Ethernet #1" then do shell script "/usr/sbin/networksetup -setairportpower airport off" delay 0.5 do shell script "scselect 1824XX49-ADE6-496F-A107-B2F7F57903F5" <<example string<< end if end if end tell
0
Apple Support Community member·
Imported from the Apple Support Forums via the Wayback Machine 🔗
thanks a lot. this is even more than i wanted . I should have mentioned that I knew one could do it with scselect but I really wanted to know why the native apple script method described in that apple tutorial is not working. either I'm missing something really obvious there (can't think what though) or it's a bug.
0
Apple Support Community member·
Imported from the Apple Support Forums via the Wayback Machine 🔗
tht page is a Leopard page (and in fact that code works perfectly on my 10.5.8). Snow Leopard may have changed things, but I don't have access to the System Preferences dictionary to see if there's any differences. I'd guess there are, though, judging by results...
0
Apple Support Community member·
Imported from the Apple Support Forums via the Wayback Machine 🔗
You're quite welcome. From what I understand "/usr/sbin/networksetup -setairportpower airport on" used to be "/usr/sbin/networksetup -setairportpower on". That was what I had to change when I went to Snow Leopard.
0
Apple Support Community member·
Imported from the Apple Support Forums via the Wayback Machine 🔗
twtwtw wrote: tht page is a Leopard page (and in fact that code works perfectly on my 10.5.8).
really? It does nothing on my 10.5.8 powerbook as I mentioned in my first post. does it really change the location for you when you look in network system preferences?
Snow Leopard may have changed things, but I don't have access to the System Preferences dictionary to see if there's any differences. I'd guess there are, though, judging by results...
0
Apple Support Community member·
Imported from the Apple Support Forums via the Wayback Machine 🔗
V.K. wrote: really? It does nothing on my 10.5.8 powerbook as I mentioned in my first post. does it really change the location for you when you look in network system preferences?
yeah, it does. if it doesn't on yours the only thing I can imagine is that you have a typo in the location name you're using (a space or non-printing character, maybe?)
0
Apple Support Community member·
Imported from the Apple Support Forums via the Wayback Machine 🔗
nope, no typos. in fact, if I put a wrong location the script returns an error when it runs.
0
Apple Support Community member·
Imported from the Apple Support Forums via the Wayback Machine 🔗
fascinating. are you seeing any errors in Console?
0
Apple Support Community member·
Imported from the Apple Support Forums via the Wayback Machine 🔗