Q:

LWP::UserAgent's env_proxy gives "Access is denied" for non-admin users

Environment:
- Active Perl 5.16
- Windows 2003 Server
- IIS 6 with Windows Authentication
I was trying to use the Perl module "LWP::Simple" in a Perl CGI script, and it worked fine for "admins" on the Server (with Windows Authentication, the IIS/CGI environment knows the users Windows username and some of us (like me) are admins on the server).  However, for all the rest of our non-admin users, they were getting "The specified CGI application misbehaved by not returning a complete set of HTTP headers".  I narrowed it down to the "use LWP::Simple" line; if the line was in, the non-admins got the error; if the line was out, no error for anyone.
Since this was a "use" line, it seemed to me impossible to debug the error under IIS (no decent error logs!), so I broke down the LWP::Simple module (which just uses a lot of LWP::UserAgent stuff) and created the following simple script to reproduce the underlying error:
#!perl

use strict;
use warnings;

use CGI::Pretty qw(:standard -any -no_xhtml -oldstyle_urls *center);
use CGI::Carp qw(fatalsToBrowser set_message);
use LWP::UserAgent;

print header;

my $ua = LWP::UserAgent->new;  # we create a global UserAgent object
$ua->env_proxy;
print "<hr>\n";

my $response = $ua->get('http://search.cpan.org/');

if ($response->is_success) {
     print $response->decoded_content;  # or whatever
}
else {
     die $response->status_line;
}

Since the error is not happening in a "use" line, we don't get the dreaded missing-http-headers error, and the real error appears on the screen:
Access is denied

This allowed me to narrow down to ONE line:
$ua->env_proxy;

If that line is in the code, the words "Access is denied" is shown on the screen for non-admins (admins do not get any errors).  In both cases, the rest of the script works fine, but this error is preventing LWP::Simple from working at all (the error occurs in a "use" line and gives the missing-http-headers error).
While my workaround is to NOT use LWP::Simple and instead use LWP::UserAgent (skipping the "$ua->env_proxy" part), I would really like to know WHY "$ua->env_proxy" gives "Access is denied" for non-admins.
Can anyone help me figure that out?

A:

Closing out this old question of mine.
The underlying problem is a system call to chcp, which is an admin-only Windows command.  There is no "clean" solution.  Either comment out the line to that call, or put another chcp in your path that will be found before the built-in/admin-only version.
Thanks to @ikegami for the insightful comments that at least helped me figure out the "why", even if there wasn't a clean fix.

