Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically Change System Network (Proxy) settings

Is there a way, from within a Cocoa application to change the system network settings (specifically, the proxy settings). I've found that there is a file called preferences.plist in /Library/Preferences/SystemConfiguration that has the settings I want, but I can't figure out how to get the system to process changes to this file without rebooting.

Can this be done programmatically, or at least by launching some command? (This solution would probably be 10.5.x only, I'm assuming)

Since I can change these settings in System Preferences immediately, there must be some way, it just eludes me ....

Thanks!

like image 890
MarcWan Avatar asked Jul 08 '09 04:07

MarcWan


People also ask

How do you change proxy settings in a script?

To set up a proxy server using a setup scriptSelect the Start button, then select Settings > Network & internet > Proxy. If you or your organization uses a setup script, next to Use setup script, select Set up. In the Edit setup script dialog box, turn on Use setup script, enter the script address, then select Save.


1 Answers

You want the SystemConfiguration framework, specifically the Proxies Dictionary (see here for more details).

like image 117
Alex Martelli Avatar answered Oct 03 '22 08:10

Alex Martelli