http://qs1969.pair.com?node_id=1131457

techman2006 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to use system command from a Perl script which get invoked from another program. During the execution I get error as below

Can't spawn "cmd.exe": No error at <Program>

When I run it from the cmd.exe the Perl script works fine and system command works as expected. So it seems that system command is not able to read ComSpec environment variable which has the cmd.exe path. So how I can tell system command for this environment variable.

I will update the question with sample code shortly.

Replies are listed 'Best First'.
Re: Windows system command fails with error can't spawn "cmd.exe"
by ww (Archbishop) on Jun 22, 2015 at 14:46 UTC

    You may draw some inferences (since you haven't shown the code that produces your data) from running this:

    C:\>dir CMD.exe /s

        ...and this:

    C:\>dir c:\Windows\System32\cmd.exe

    Further hint: what's your CWD when you try to spawn?

Re: Windows system command fails with error can't spawn "cmd.exe"
by Anonymous Monk on Jun 22, 2015 at 11:32 UTC