The other way of running a process on windows is for it to have its own window handling function (WinMain). In this case, the process doesn't have an associated console window (or STDIN, STDOUT and STDERR) and is able to create its own windows if it chooses. This is what the vast majority of 'normal' windows applications do.
This is slightly misleading. I'm no expert at all but it appears that a .exe header has "slots" for some kinds of executable breeds, to be handled by separated subsystems. One of these is CONSOLE which provides a console to "attach" STDIN, STDOUT and STDERR, and another one is WINDOWS, which does not provide it, for applications that do not need it. But applications of both types may create their own window(s). Indeed newbies at Tk and other toolkits in Win* envs often get annoyed by the pop-up console they get on clicking on their script, and then they're rightly pointed to wperl.exe, however there may well be a console application with a GUI part, although that's simply not common:
#!/usr/bin/perl -l use strict; use warnings; use Tk; { print "Do you want to press some buttons? (Y/N) [Y]"; chomp(my $in=<STDIN>); $in='y' if $in eq ''; my $cmd={ y => sub {}, n => sub { die "So long then...\n"; } }->{lc $in} || redo; $cmd->(); } my $mw=MainWindow->new; $mw->title('Button 2 STDOUT example'); for my $msg (qw/foo bar baz/) { $mw->Button(-text => "Print '$msg' to STDOUT", -command => sub {print $msg})->pack } $mw->Button(-text => 'Exit GUI', -command => [$mw => 'destroy'])->pack; MainLoop; print "It has been unforgettable!"; __END__
You can run your perl script in this second form by using the "wperl.exe" perl interpreter, which should be in the same place as your "perl.exe".
Indeed I believe wperl.exe is "built" by exetype.bat, also distributed with ActivePerl. The latter in turn is just a Perl script itself and a quick look at it reveals it just changes the value of a few bits in the executable it is passed.
In reply to Re^2: Running scripts normally without using shell?
by blazar
in thread Running scripts normally without using shell?
by newbie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |