I'm trying to run a script that calls child processes on Windows XP. It was originally designed in Windows 7. Everything seems to work save the spawn:
I run a command
system "start", "cmd.exe", "/k","C:/path/perl.exe","C:/users/script.pl";
in Windows 7, and it spawns script.pl
into a new console.
The same command in XP tells me that it can't find start
.
When I run
system "cmd.exe", "/k","C:/path/perl.exe","C:/users/script.pl";
It doesn't open a new console.
How do I spawn a new process in a new console in XP?
I can't remember a thing about XP, but on W7 start
is provided by cmd.exe
and isn't a separate executable. So I'm surprised to see it first in the list of parameters.
I think the original author screwed it up badly so that cmd.exe
is run implicitly to do the start
, which then runs a second copy of cmd.exe
which runs perl.
In the end, I assume you want to run the Perl program and wait until it completes, so you need
system qw{ cmd.exe /K C:/path/perl.exe C:/users/script.pl }
I also think the /K
should be /C
, as the former asks for another prompt from the shell once the command exits, whereas the latter just runs the command and stops.
Check your mileage.
Oh, and you can't use qw
as I have if there are spaces in the paths.