Windows runs PAC files differently from Chrome and Firefox
Chrome, Edge and Firefox run a PAC file in their own engine. Windows services and many Windows programs run it in the Windows engine instead, and that engine answers some calls in its own way. A file that works in the browser can send these programs to the wrong place.
Source for every statement on this page: lab, Windows 11 25H2, 2026-10-11; statements that name a later date come from later lab runs.
Windows has its own PAC engine
A PAC file (proxy auto-config file, often called proxy.pac or wpad.dat) is a small JavaScript
program. Each client runs it to decide which proxy to use for an address. Chrome and Edge run it in
their own engine, also on Windows. Windows services, the background download service BITS, and
programs that use the Windows proxy settings run it in an engine that is part of Windows. Programs
reach that engine through WinHTTP and WinINet, the two network libraries of Windows, or through .NET
and Java.
The points below are the places where that engine answers differently from Chrome and Firefox. Each one can make a file that passes a browser test go wrong for Windows programs.
Time-based rules never apply on Windows: dateRange and timeRange are always false
A PAC file has three helper functions for time: dateRange() for days, months and
years, timeRange() for the time of day, and
weekdayRange() for days of the week. On Windows, dateRange() and timeRange()
returned false for every form of argument that was tried. That includes calls that cover the current date
or time in any case, such as dateRange(2020, 2030), dateRange("JAN", "DEC"), timeRange(0, 24) and the
forms with minutes, seconds or "GMT".
A branch that needs one of these functions to be true is therefore never taken by Windows services, BITS and programs that use the Windows proxy settings, and no error appears anywhere. Chrome, Edge and Firefox take the same branch when the date or time is in range. The same file sends browsers and Windows programs to different places, and only at the times the rule was written for (PAC-K007).
What to do:
- Apply time-based policy on the proxy. The proxy knows the time and applies the rule the same way for every client, whatever engine runs the PAC file.
- Make the answer without the time rule the safe one. If the time rule has to stay in the file, write it so that the branch Windows takes, the one where the time function is false, gives an answer you accept.
- Write day names in upper case, as the next section explains.
weekdayRange on Windows needs upper-case day names
weekdayRange() works on Windows, including ranges across the weekend such as
weekdayRange("FRI", "MON"). It accepts only upper-case day names such as "MON". With
weekdayRange("mon", "fri") the call throws an error, which stops the script, while Chrome just
returns false. weekdayRange("MON", "FRI") works on Windows and in the browsers.
shExpMatch on Windows is a plain wildcard match
On Windows, shExpMatch() knows only two special characters: * for any
text and ? for one character. Characters that have a meaning in a regular expression (the pattern
language that the browsers use inside this function), such as [ ] + ( ) $ |, are compared as
ordinary characters on Windows. A pattern like "[ab]bc" therefore matches different strings on
Windows and in Chrome (PAC-K015). The match is case-sensitive,
as in the browsers.
Newer JavaScript makes the whole file fail on Windows
The Windows engine understands JavaScript up to about the 2017 version of the language. let,
const, arrow functions, classes and template strings work. Optional chaining (a?.b), the ??
operator and object spread ({...o}) are syntax errors, and then Windows cannot run the file at all,
for any address (PAC-K020). Some newer built-in functions, such as
replaceAll and Object.fromEntries, do not exist there either
(PAC-K010).
A badly written return value sends Windows programs direct
The function FindProxyForURL returns a text such as "PROXY proxy.corp.example:8080; DIRECT".
If the ; before DIRECT is missing, as in "PROXY proxy.corp.example:8080 DIRECT", Windows goes
direct, and Chrome did the same in the same test. Lower-case keywords are where Windows differs: Chrome accepts "proxy p.corp.example:3128", but Windows ignores
the entry and goes direct (PAC-E011). Write the keywords PROXY,
DIRECT and SOCKS in upper case and separate the entries with ;.
Older Windows programs drop SOCKS and everything after DIRECT
Programs built on .NET Framework or .NET receive only the proxies listed before the first DIRECT,
and they receive no SOCKS proxy at all. A PAC answer
that contains only a SOCKS proxy therefore sends them direct
(PAC-K005, PAC-X014).
Put an HTTP proxy (PROXY) first if these programs have to use a proxy.
Windows keeps one answer per host and does not look at the path again
WinHTTP runs the script once for a host and reuses the answer for later addresses on the same host,
even when the path or the port is different. Desktop programs that use WinINet do the same: in the lab, the
first http request to a host ran the script, and every later http request to that host, with another path
or on another port, used that first answer (Windows 11, 2026-10-15). The very first request of a program, the
one that makes it download the PAC file, is an exception: for it the script ran twice in a row, for an http and
for an https request alike, and the program used and kept the second answer. A request also ran the script a second
time, and waited for both runs, when Windows downloaded a PAC file while the request’s script was running: the
program’s own file at one of the scheduled downloads described below, or the file of another program that used a different PAC address. This
happened to every such request in the lab (147 of 147), whether the script was waiting for DNS answers or
busy computing, and no request ran the script more than twice. When only the program’s own file was downloaded,
Windows waited until the running request was done and did not repeat it. Every other request ran the script once,
also the first request after a scheduled download (lab, Windows 11, 2026-10-16). The answers are kept until the
PAC file is downloaded again, and each time that happens every kept answer is dropped at once, also
for a host that had been used a minute before. The program does not choose that moment itself: the web server
sees the download come from the WinHTTP Auto-Proxy service (User-Agent WinHttp-Autoproxy-Service/5.1),
which downloaded the files of all running programs again in the same second. In the lab this happened on
one schedule for all programs, alternately 10 minutes 9 seconds and 11 minutes 5 seconds apart, so a program
got its first new download anywhere from a minute to 11 minutes after it started; once no download came for
22 minutes. Windows also forgets a file that is not used. A file that a program used at least every 5.5 minutes
was always kept; after 6 to 7 minutes without use it was sometimes gone, and after 7 minutes always. A scheduled
download counts as use, just as a request does. At a scheduled download Windows also left some files out and
forgot them, once a file that had been used 14 seconds before; what decides this is not known. The next request
of such a program downloads the file itself and, like a first request, runs the script twice. Programs that
use the same PAC address share one loaded copy of the script: new programs with an address that was already
loaded used that copy and ran their first request once. A file that had been changed during such a pause was
downloaded in full by the next request and used for it at once. The PAC file’s caching headers made no difference: with Cache-Control: max-age=60, max-age=1800,
no-cache, no-store, an Expires date or an old Last-Modified date, the files were downloaded at the same
moments, and always in full (lab, Windows 11, 2026-10-15). How many hosts a program had asked for made no difference
in the lab. A rule that sends /download/ to another proxy than
the rest of the host is therefore not checked again. For https:// addresses the script never sees
the path anyway, because Windows passes only the scheme, the host and the port
(PAC-K021). Some programs, such as Java, do not pass the path of
http:// addresses either.
A proxy administrator may notice HEAD / requests without a User-Agent in the proxy log, addressed to the
proxy itself (Host: is the proxy’s name and port). After each new download of the PAC files, Windows sends one such
request to the first proxy of one answer, and to the next proxy of the same answer when the
first one refuses it. In the lab, a proxy that answered it with 405 Method Not Allowed or closed the
connection without an answer still got all of the program’s requests; the request only checks, it does not
change the route (lab, Windows 11, 2026-10-15).
An endless loop blocks Windows programs because there is no time limit
Windows does not stop a PAC script that runs too long. In the lab, a script with an endless loop blocked the waiting program for more than 18 minutes, until it was stopped by hand (PAC-E008, PAC-E007). Make sure that every loop in the file ends.
WinHTTP and WinINet: what they share and where they differ
Windows has two network libraries that run PAC files. WinHTTP serves Windows services, the background download service BITS and programs written for WinHTTP. WinINet serves desktop programs that follow the Windows proxy settings, and .NET and Java programs reach the same engine in the same way. Both run the file in the same script engine, so almost everything on this page applies to both. They differ mainly in what they pass to the script.
| Behaviour | WinHTTP | WinINet (also .NET, Java) |
|---|---|---|
| Programs that use it | Windows services, BITS, programs written for WinHTTP | Desktop programs that follow the Windows proxy settings, .NET, Java |
| Script engine and JavaScript level | About ES2017; ?., ?? and object spread are syntax errors | Same |
| PAC functions | All 19, including the Microsoft *Ex functions | Same |
dateRange() and timeRange() | Always false | Same |
weekdayRange() | Upper-case day names only | Same |
| Time limit for the script | None | Same |
| Error thrown by the script | The program gets an error, not DIRECT | Same |
| How the returned string is read | Loosely; a missing ; before DIRECT sends traffic direct | Same |
myIpAddress() | First adapter by interface metric | Same |
| Largest PAC file | About 1 MiB | Same |
| Host name case | Kept as typed, for example Example.COM | Lower-cased; an IPv6 address such as [FD00::A1] keeps its letters |
Final dot after the host name (intranet.corp.example.) | Kept in host and url | Same |
International host name (bücher.example) | Lower-case punycode, xn--bcher-kva.example; the other parts of the name are lower-cased too | Same |
Path in http:// URLs | Passed to the script | Passed by WinINet and .NET; Java cuts it |
| User name and password in the URL | Removed | Removed |
| One answer reused per host | Yes, also for another path or port | Same; the answer for the first request to a host is used for the later ones until the PAC file is downloaded again (in the lab about every 10 to 11 minutes, whatever the caching headers, and after about 6 to 7 minutes without use) |
HTTPS proxy:port in the answer | A program that uses the entry opens TLS to the proxy; with a wrong proxy certificate the request fails | The request goes to the proxy over TLS; if TLS to it fails, the next PROXY entry is used |
| DNS lookups | About 12 s per call when DNS does not answer, also inside one run | Same, but a request runs the script twice, and so waits twice as long (24 s for one such lookup), when it makes the program download the PAC file (its first request, and the first after about 6 to 7 minutes without use) and when Windows downloads a PAC file while the request’s script is running |
Because WinHTTP keeps upper-case letters and dnsDomainIs() and
shExpMatch() are case-sensitive, the same file can route Example.COM differently in a Windows
service than in a desktop program. Chrome, Edge and Firefox behave like WinINet here: they pass the
host in lower case (lab, 2026-10-15). The WinINet values for the final dot, international names, the user name and password, the
reused answer and the DNS wait come from requests that a WinINet program made in the lab on the same
day. The DNS wait of both was measured again on 2026-10-16 with the same result; the double runs, and how long Windows
keeps a program’s PAC file, were measured on that day too. Call host = host.toLowerCase(); at the start of the file
(PAC-K009). The engine pages
Windows WinHTTP and Windows WinINet list every value with
its source.
Test the file with the Windows profile
The PAC file tester has two Windows profiles: “Windows WinHTTP” for Windows services, BITS and programs that use WinHTTP, and “Windows WinINet” for desktop programs, .NET and Java programs that follow the Windows proxy settings. Paste your file, enter a URL and pick a Windows profile. The trace shows which test and which line decided, and the rating flags the calls that Windows answers differently. The engine pages for Windows (WinHTTP) and Windows WinINet list the details, and pactester vs Chrome and Firefox covers the other engines.
Frequently asked questions
Why does my PAC file work in Chrome but not in Windows programs?
Chrome and Edge run the PAC file in their own engine, also on Windows. Windows services and programs that use the Windows proxy settings run it in the Windows engine, which answers some calls differently. dateRange and timeRange are always false there, weekdayRange stops the script on lower-case day names, and newer JavaScript such as ?. or ?? makes the whole file fail. Test the file with a Windows profile in the tester at findproxyforurl.net/check/.
Do dateRange and timeRange work in a PAC file on Windows?
No. On Windows 11 25H2, dateRange() and timeRange() returned false for every form of argument that was tried, including dateRange(2020, 2030), dateRange("JAN", "DEC") and timeRange(0, 24), which cover the current date and time. Chrome, Edge and Firefox return true for these calls. A rule that depends on them never applies to Windows services or Windows programs.
How do I make a time-based PAC rule work on Windows?
Move the time rule to the proxy, which knows the time and applies it the same way for every client. If it has to stay in the PAC file, write the file so that the branch Windows takes when the time function is false is an answer you accept, write day names for weekdayRange in upper case, and test the file with a Windows profile at findproxyforurl.net/check/.
Does WinHTTP support let and const in a PAC file?
Yes. In the lab on Windows 11 25H2, let, const, arrow functions, classes and template strings worked. Newer syntax such as optional chaining (?.), the ?? operator and object spread ({...o}) is a syntax error, and then the whole file fails.
Is shExpMatch case-sensitive on Windows?
Yes, as in the browsers. On Windows, shExpMatch is a plain wildcard match in which only * and ? are special. Characters that mean something in a regular expression, such as [ ] + ( ) and $, are compared as ordinary characters, so some patterns match on Windows and not in Chrome, or the other way round.
Why do some Windows programs ignore the SOCKS proxy in my PAC file?
Older Windows programs, for example those built on .NET Framework or .NET, receive only the proxies that come before the first DIRECT and receive no SOCKS proxy at all. A PAC answer with only a SOCKS proxy sends them direct.
Does Windows run the PAC file again for every URL?
No. WinHTTP, the library of Windows services, and WinINet, the library of desktop programs, keep one answer per host and reuse it for other paths and ports on the same host, so a rule that looks at the path is not checked again. For https addresses the script never sees the path at all.