Under Mac OS X Version 10.1.5, how do you script changing the current “Location” in System Preferences “Network”. Everything that I have tried so far has not worked.
I know of no preference panes that are scriptable but it is sometimes possible to change settings by manipulating preference files/plists or, in OS X 10.2.3 or later, by using GUI Scripting, which is still in beta.
If you use a utility that allows you to assign custom keyboard commands to menu items, you could assign a keyboard command to each location and then use Extra Suites to simulate the keyboard commands with a script.
set the_location to (choose from list (my switch_location("", true)) with prompt "Choose a Location to Activate:" OK button name "Activate")
if the_location = false then return
my switch_location(the_location as string, false) --of course you could hard code it: my switch_location("home", false)
on switch_location(the_location, return_locations)
tell application "System Events"
tell (item 1 of (processes whose frontmost = true))
tell menu bar 1
tell menu bar item "Apple"
tell menu "Apple"
tell menu item "Location"
tell menu "Location"
if return_locations = true then return name of menu items
click menu item the_location
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end switch_location
Can someone help me find a way to CREATE a specific Computer-to-Computer network upon start up? It seems like this is close?
Thanks,
Peter
PS: My laptop got swept off a table top by a stiff wind, smashing the screen. I want to be able to use airport networking to let my new MacBookPro use the broken Mac’s internal Modem. I have been able to set up a computer-to-computer network via airport and it works fine. The only problem is I have to plug the broken Mac into a projector to see the “screen” to go under the airport menu and create the network. I would like to automate this. The network is to be named “SmashedMac HD” . Thanks in advance for an Applescript to operate at start up on the broken Mac to create the computer to computer net ???
Model: MBpro 2.33GHz, 2GB ram
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
Hi Jon, this script doesn’t cause the creation of a computer-to-computer network. It generates a box someone has to physically click to select a location. That is not what is needed. I am seeking to have the machine CREATE a new airport network upon startup called SmashedMac HD, that is secured (5 characters) and selected in the airport menu.
Thank you gentlepersons, I will try your suggestions and persevere! This is really tough for a beginner… I haven’t seen any good tutorial sites that deal with Applescripting the Airport Menu, specifically assigning a computer to computer networking name and encryption. Thanks for the continued assistance!
peter
I tried your suggestion and get this error message:
Set “DHCP” not available.
Defined sets include: (* == current set)
the there is a list of my locations. but the script or command doesn’t lead me anywhere near setting up an airport network!
Hello!,
I’m looking for a way to automate the creation of ad hoc network too, with no luck.
I have installed XNetwork 2.0 but running the creation script I got a 4113 error (???).
create ad hoc wireless network "huntz's Net" password "1234567890123"
Is it available under OS X an utility like iwconfig under Linux?
Well it’s consistent anyway; I get exactly the same result. I’m suspicious that XNetwork 2.0 is not up to speed on the latest security additions in OS X 10.4. It is dated on my machine in May of 06, several versions of the OS back.
Thank you for the reply, Adam.
I have also tested the ascii password option with buggy results (the error change, and the XNetwork class is not able to correctly handle any password used…)
So:
a) or XNetwork is outdated
b) or XNetwork is buggy (at least the ad hoc stuff)
And the bad news is no activity and reply on the XNetwork website…