set a DNS entry in the Network Preference Pane

hello,

i’ve been working on a script to enable the local caching DNS server. thanks to help from Adam Bell and Bruce Philips, i was able to get user input validation and such done earlier today. my final problem is to either:

  1. set the DNS entry in the Network Preference Pane to ‘127.0.0.1’
    or
  2. open the Network Preference pane to the default location and give a dialog box that encourages the user to make the change.

i’ve tried the former and have had no luck. i’ve set the DNS entries with ‘scutil’ and even rewritten /etc/resolv.conf (before i realized that i should not do that). i’ve settled on trying to do the latter, but the only code i can come up with just opens the Network Preference Pane and doesn’t go any deeper. here is the code:


on setLocalPref()
	tell application "System Preferences"
		activate
		set current pane to pane "com.apple.preference.network"
		display dialog "Please take out any 'DNS Servers' and replace them with '127.0.0.1'"
	end tell
end setLocalPref

i will be posting the entire script in Code Exchange, but i can post it here if anyone would like to see it. it’s based on this article:

http://www.macosxhints.com/article.php?story=20050420025219402

cheers.

EDITED TO ADD: i almost forgot–i’d rather not do GUI Scripting since i’ll be distributing this. i can’t depend on the user enabling GUI Scripting access…w