If your program doesn't require access to any of the output
from the
commands it starts, you can use Win32::Process to start
commands:
Win32::Process::Create(
my $proc_obj,
"$ENV\system32\cmd.exe",
"cmd.exe /S /C "$cmd_line "",
0,
Win32::Process::CREATE_NO_WINDOW,
$working_directory);
$proc_obj->Wait(&INFINITE);
You can also do paths directly to EXEs and modify the
command line as
required, etc.
If you want to avoid Win32::GUI, you can use the following
Win32::API
code that will do the same thing that Win32::GUI is doing
below:
use Win32::API 0.41;
{
my $call;
sub GetConsoleWindow {
$call ||= Win32::API->new('kernel32',
'GetConsoleWindow', '', 'I') or
Carp::croak("Unable to connect to
GetConsoleWindow.");
return $call->Call();
}
}
{
my $call;
sub ShowWindow {
my($hWnd, $iCommand) = _;
$call ||= Win32::API->new('user32',
'ShowWindow', 'II', 'I') or
Carp::croak("Unable to connect to
ShowWindow.");
return $call->Call($hWnd, $iCommand) ? 1 : 0;
}
}
&ShowWindow(&GetConsoleWindow(), 0x00 );
The central problem is that for a process to have access to
the output
of another command, the process needs to have an associated
console
(although the console can be hidden or detached). So far as
I know,
there is no way to mark an EXE (any EXE) so that it starts
with a hidden
console. It would be a nice feature for PerlApp, however,
to have the
ability to build an EXE that would hide the console very
early on during
the execution (i.e. before it got all the Perl code ready to
execute).
Of course, really nice would be if it could somehow figure
out if it was
sharing a console with something else already (i.e. CMD.EXE
or some
other shell), in which case it wouldn't hide the console, or
if it was
the first EXE in the console, in which case it would know to
hide
itself.
--Toby Ovod-Everett
_______________________________________________
PDK mailing list
PDK listserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
|