Subject: | BUG in Win32::Job: Unable to run job as user other than user logged into machine |
Date: | Fri, 22 Feb 2008 10:33:16 -0500 |
To: | <bug-libwin32 [...] rt.cpan.org> |
From: | "Steven Del" <sdel [...] ansoft.com> |
Bug: Unable to run job as user other than user logged into machine
Module: Win32::Job
libwin32 version: 0.28
perl -v output:
perl -v
Show quoted text
> This is perl, v5.8.8 built for MSWin32-x86-multi-thread
> (with 18 registered patches, see perl -V for more detail)
>
> Copyright 1987-2007, Larry Wall
>
> Binary build 822 [280952] provided by ActiveState
http://www.ActiveState.com
Show quoted text> Built Jul 31 2007 19:34:48
>
> Perl may be copied only under the terms of either the Artistic License
or the
Show quoted text> GNU General Public License, which may be found in the Perl 5 source
kit.
Show quoted text>
> Complete documentation for Perl, including FAQ lists, should be found
on
Show quoted text> this system using "man perl" or "perldoc perl". If you have access to
the
Show quoted text> Internet, point your browser at http://www.perl.org/, the Perl Home
Page.
Description:
As a user logged into the console, run the attached code sample,
assuming you have a file c:\echo_path.bat that is valid. It will
succeed. However, if while logged in as this user, you open a command
prompt as another user (run "runas /user:<other user> cmd"), and then
you attempt to run the below code, $job->spawn fails and returns "Access
is denied" in $^E. I can run the Windows batch file directly, meaning
the issue must have to do with the job itself.
Perl code sample:
#!perl
use Win32::Job;
my $job = Win32::Job->new;
my $test_cmd = "c:\\echo_path.bat";
my $pid = $job->spawn(undef, $test_cmd); # THIS LINE RETURNS UNDEF
if ( ! $pid )
{
print "*** Error: Unable to run command: ${test_cmd}:\n";
print " " . $^E . "\n";
exit(1);
}
my $ok = $job->run(30, 1);
my $retval = $job->status->{$pid}->{exitcode};
if ( $retval == 293 )
{
print "### Warning: Timed out:\n";
print " ${test_cmd}\n";
}
exit(0);