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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.