I will suggest you to use the MS Scripting pages. If you go to this site, you will find a script to retrieve the TCP/IP configuration of your client (http://www.microsoft.com/technet/scriptcenter/scripts/network/client/list/nwlsvb02.mspx). With this information, particularly with the DNS Suffix, you can determine if your client is local or remote.
Then you can use a script (http://www.microsoft.com/technet/scriptcenter/scripts/os/registry/osrgvb04.mspx) to update the registry key “HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet SettingsProxyEnable”
I let you the pleasure to write the definitive script.