in reply to Windows 10 Command Prompt

Hello PilotinControl

I see no differences in win7 win10 behaviour for the following simple script (removing sounds and other amenities)

use strict; use warnings; $|++; #autoflush output quit(); sub quit { my $sleep = 3; while ( $sleep ){ print "\rQuitting in $sleep sec."; sleep 1; $sleep--; } exit; }

I find no differences even if the .pl program is doubleclicked AND .pl files are associated with a valid perl.exe interpreter. Is this your use case? Because normally a command prompt previously started is persistent. Anyway in both circumstances and in both OSs I see no different behaviour.

You can be interested in a more complex solution as you can read in Handling MSWin Script Output, where I posted the following code:

use strict; use Win32::Process::Info; my $pihandle = Win32::Process::Info->new(); my @procinfo = $pihandle->GetProcInfo(); my $ParentPID; my %ProcNames; foreach my $PIDInfo (@procinfo) { $ProcNames{$PIDInfo->{ProcessId}} = $PIDInfo->{Name}; if ($PIDInfo->{ProcessId} == $$) { $ParentPID = $PIDInfo->{ParentProcessId}; last; } } print "Parent's name is [", $ProcNames{$ParentPID}, "]\n"; if ( $ProcNames{$ParentPID} eq 'OpenWith.exe' or $ProcNames{$ParentPID +} eq 'explorer.exe') { print 'Press ENTER to close the window: '; <>; } else{ print "..exiting normally\n"; }

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.