I am trying to create a pack file for teacher's laptops which will set the proxy settings when in school but use direct when at home. Can anyone provide a working example as all the ones I have done so far don't seem to work.
Thanks.
Have no idea what a PAC file is, but I use a vb script to achieve the same thing.
Enables / disables the use proxy setting tick box. Nice and simple.Code:Const HKEY_CURRENT_USER = &H80000001 intmsg = msgbox("CHANGE PROXY SETTINGS" & chr(13) & "ARE YOU AT HOME?",vbYesNo+vbQuestion,"WHERE ARE YOU?") if intmsg = vbyes then dwvalue = 0 else dwvalue = 1 strComputer = "." Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" strValueName = "ProxyEnable" objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue msgtxt = "THE PROXY SERVER HAS BEEN " if dwvalue = 0 then msgtxt = msgtxt & "DISABLED" if dwvalue = 1 then msgtxt = msgtxt & "ENABLED" intmsg = msgbox(msgtxt,vbOKOnly+vbInfo,"Done")
Originally Posted by u8dmtm
Code:function FindProxyForURL(url,host) { if (localHostOrDomainIs(host, "carrhill.lancs.ac.uk")) return "DIRECT"; if (localHostOrDomainIs(host, "lancsngfl.ac.uk")) return "DIRECT"; if (isInNet(host, 10.73.24.0, 255.255.252.0)) return "DIRECT"; if (url.substring(0, 6) == "https:") return "PROXY proxy.lancsngfl.ac.uk:8080; DIRECT"; if (url.substring(0, 5) == "http:" || url.substring(0, 4) == "ftp:") return "PROXY proxy.carrhill.lancs.sch.uk:8080; DIRECT"; return "PROXY proxy.carrhill.lancs.sch.uk:8080"; }

Here's a similar one I made to respond to command-line arguments, ideal for making shortcuts to specify which proxy to use and/or enable/disable it.
proxy.vbs Off No - Disables access via proxy with no confirmation it has been done.
proxy.vbs Off Yes - Disables access via proxy but display confirmation it has been done.
proxy.vbs On Yes - Enable proxy access - set to the server specified in the .VBS file itself and show confirmation.
proxy.vbs On 172.16.8.254:8080 No - Enable proxy access - set to the server '172.16.8.254:8080' but don't show confirmation.
proxy.vbs
Code:Set WSHSHell = WScript.CreateObject("WScript.Shell") Dim Key,proxyInt,proxyExt,ProxyServer,Args,Num,UseProxy Key = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\" ' Available proxies ' proxyInt = "10.0.0.1:8080" proxyExt = "ext.proxy.ip.address:8080" ' Default proxy to set in the Registry if none is passed via arguments ' ProxyServer = proxyInt Set Args = WScript.Arguments Num = Args.Count If Num = 0 Then MsgBox "Usage: [CScript | WScript] proxy.vbs <On|Off> <server:port> <Yes|No>" & vbCrLf & vbCrLf & "On|Off" & vbTab & vbTab & "-- Toggle access via proxy." & vbCrLf & "server:port" & vbTab & "-- Proxy server & port combo" & vbCrLf & "Yes|No" & vbTab & vbTab & "-- Confirmation of on or off message" & vbCrlf & vbCrLf & "i.e. 'proxy.vbs On 10.0.0.1:8080 Yes' to use proxy and display confirmation ", vbInformation, "Proxy" WScript.Quit 1 End If For i = 0 to Num-1 Cmd = Args.Item(i) Select Case Cmd Case "On": UseProxy = TRUE Case "Off": UseProxy = FALSE Case "Yes": Confirm = TRUE Case "No": Confirm = FALSE Case Else: ProxyServer = Cmd End Select Next If UseProxy = TRUE Then WshShell.RegWrite key & "ProxyEnable", 1, "REG_DWORD" WshShell.RegWrite key & "ProxyServer", ProxyServer, "REG_SZ" ConfirmText = "Internet access via proxy is enabled through:" & vbCrLf & vbCrLf & ProxyServer ConfirmIcon = vbInformation ConfirmCapt = "Proxy ON" ElseIf UseProxy = FALSE Then WshShell.RegWrite key & "ProxyEnable", 0, "REG_DWORD" ConfirmText = "Internet access via proxy is turned *OFF*" ConfirmIcon = vbCritical ConfirmCapt = "Proxy OFF" End If If Confirm = TRUE Then MsgBox ConfirmText, ConfirmIcon, ConfirmCapt End If

proxyconfig.pac
browser independant OS independant, Here's ours:
Code:function FindProxyForURL(url, host) { // variable strings to return var proxy_yes = "PROXY 172.16.0.3:8080"; var proxy_no = "DIRECT"; if (shExpMatch(url, "http://intranet/*")) { return proxy_no; } if (shExpMatch(url, "http:/intranet:8080/*")) { return proxy_no; } // Proxy anything else return proxy_yes; }
There are currently 1 users browsing this thread. (0 members and 1 guests)