Applescript for creating Ad-hoc network in Lion...

With a great deal of help from ljr_nbg and the tutorials on this forum I was able to piece together some scripts that I found here to solve my problem…

http://forums.presonus.com/posts/list/21262.page
http://hints.macworld.com/article.php?story=2008081808383349

So now it turns on Wi-Fi if off, creates an ad-hoc network with 128-bit security and signs in. Hope this can help somebody someday.

For OSX Lion 10.7.3

property NetworkName : "Your Network Name"
property NetworkPassword : "thirteenchara"
property BringupScript : ""
tell application "System Events"
	tell process "SystemUIServer"
		tell menu bar 1
			-- Find Airport Menu
			set menu_extras to value of attribute "AXDescription" of menu bar items
			repeat with the_menu from 1 to the count of menu_extras
				if item the_menu of menu_extras contains "Wi-Fi" then exit repeat
			end repeat
			
			-- Turn on airport and start create network
			tell menu bar item the_menu
				perform action "AXPress"
				-- If Wi-Fi is off, turn it on
				if title of menu item 2 of menu 1 is "Turn Wi-Fi On" then
					perform action "AXPress" of menu item "Turn Wi-Fi On" of menu 1
					perform action "AXPress"
				end if
				perform action "AXPress" of menu item "Create Network." of menu 1
			end tell
		end tell
		
		-- Enter information into Create Network Dialog
		tell window 1
			click pop up button 2
			click menu item 4 of menu 1 of pop up button 2
			set value of text field 3 to NetworkPassword
			set value of text field 2 to NetworkPassword
			set value of text field 1 to NetworkName
			click button "Create"
		end tell
	end tell
end tell

Any one know what the “BringUpScript” command is for? And why I am sometimes asked for my admin pass when running this script? Any tips on how to include a workaround for that in the script would be appreciated.

Thanks for a great forum