Under a normal interactive console the PROMPT environment variable is defined, while it is not when .PL started from Windows Explorer (double click).
I don't know if this will be the same behaviour under Windows scheduler as it is when directly using Windows Explorer, but you might try this (which works differentiating between interactive console and double-click from Windows Explorer under W7 and W10, professional editions, at least):
BEGIN {
$^O =~ /MSWin/ or die "This programme must be run under Windows.\n";
};
use strict;
use warnings;
use 5.016;
if ($ENV{PROMPT}) {
print "This programme was started from an interactive console.";
}
else {
say "This programme was started directly from Windows Explorer.";
print 'Press <return>...'; <>;
};
I suspect it might even be used under Unix: it seems to remember that, back in the days, the prompt was not defined at cron
job when using Korn shell under OSF1
(True64 Unix) from Digital.
NB: if this does not work you might try to encapsulate your Perl job in a .CMD batch file and test the difference between %CMDCMDLINE% and %COMSPEC%, this is the usual way to check if a batch file is run from a console or not.
But this is beyond the scope of your question.