in reply to system command can't spawn cmd.exe

I am not sure you gave us all the pieces of this puzzle. I see one error, and I would
like to make a suggestion.
1) As a previous reply implied, you need to back slash the space in Program Files.
2) The line
Can't spawn "cmd.exe": No such file or directory at c:\projects\runbatch.pl line 4.
is stating that whatever line 4 of c:\projects\runbatch.pl is trying to get cmd.exe
to execute is not there.

Try this
#!/usr/bin/perl -w
use strict;
my $prog = "c:\\program\ files\\agent\\agent.bat";
if (system("$prog")) {
print("Cannot system $prog:$!:\n");
} else {
print("Success\n");
}

If this does not work, please let us know what the said line 4 is.

Replies are listed 'Best First'.
Re^2: system command can't spawn cmd.exe
by oddmedley (Novice) on Oct 15, 2008 at 22:55 UTC

    I had the same problem on WinXP with Activestate 5.8.8. I tried changing the env path (quoting all the entries with spaces), changing the path temporarily in the script by setting $ENV{PATH} and in a desperate measure putting cmd.exe in the same directory as my perl script. nothing worked. Then, I tried using system like this:

    my $ret = system "C:\\WINDOWS\\System32\\cmd.exe /C $syscall";

    where $syscall is a string you set with the program you want to call and all its arguments. Worked perfectly for me, after way too long scratching my head... Anyway, I hope it helps someone else.