use Win32::Process qw(CREATE_NEW_CONSOLE STILL_ACTIVE); use Win32; my %procs=(); foreach my $a (@array) { my $cmd01 = 'some command ' . $a . ' other stuff'; my $cmd = "cmd /c echo Performing job. Please wait... & $cmd01"; my $ProcessObj; Win32::Process::Create($ProcessObj,"C:\\WINDOWS\\system32\\cmd.exe","$cmd01",0,CREATE_NEW_CONSOLE,"."); $procs{$ProcessObj} = $a; } while (%procs) { foreach my $key (keys %procs) { my $exit_code = 1; $key->GetExitCode($exit_code); while($exit_code == Win32::Process::STILL_ACTIVE()) { sleep(1); $key->GetExitCode($exit_code); } print "GetExitCode returned $exit_code, exiting main process for $procs{$key}.\n"; delete $procs{$key}; } }