7

I have started seeing some very strange issues with the pipe command not working on Windows 7 64-bit on my machine. Commands like this:

 echo test | more  

used to work without a problem, but now they fail with the following error message:

'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC' is not recognized as an internal or external command, operable program or batch file.  

It also doesn't seem to matter what is on the left and right sides of the pipe, any command line instruction with a pipe in it fails. It also doesn't seem to make a difference if the right hand side of the pipe is not a proper executable at all.

E.g. the following both exhibit the same failing behaviour:

type file1 | findstr blah
dir | thisdoesnotexist

All of these things worked fine a week ago, and I'm not sure what could have changed. There was possibly a Windows update that occurred at the time it stopped working, but I don't know for sure.

My %PATH% and %PATHEXT% environment variables both look OK too. Their contents look like the following:

Path=C:\Program Files\Common Files\Microsoft Shared\Microsoft Online Services;
C:\Program Files (x86)\Common Files\Microsoft Shared\Microsoft Online Services;
C:\Windows\system32;
C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;
C:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\;
C:\Programs\WinMerge;
C:\Programs\TortoiseHg\;
C:\Programs\MySQL\MySQL Server 5.1\bin;
C:\Programs\Aldec\Active-HDL 9.1\bin;
C:\Programs\Tcl\bin;
C:\Programs\modeltech_pe_10.0b\win32pe;
C:\Programs\Atlassian\atlassian-plugin-sdk-3.2.3\bin;
C:\Xilinx\12.4\ISE_DS\ISE\bin\nt64;
C:\altera\12.1\quartus\bin64

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC  

Using any of these commands without the pipe works fine, and redirecting to/from file works fine too. The programs appear to be exiting correctly as there is nothing appearing in any of the event logs.

Does anyone know what might be the cause of such an issue?

0

1 Answer 1

10

It looks like your ComSpec variable definition is improperly defined. The ComSpec variable should hold the full absolute path to CMD.EXE. Both sides of a pipe are executed by a new CMD thread that is launched via the definition of ComSpec. The pipe will fail if ComSpec is not valid, as is happening in your case.

I haven't figured out why that particular error message appears if ComSpec does not point to a valid executable. But I have confirmed I get that same message on Vista if I improperly set ComSpec and then try to use a pipe.

5
  • 2
    It doesn't even need to be defined to look like a value suitable for PATHEXT. As long as the path to cmd.exe is not specified properly that error occurs. Good catch! +1
    – Karan
    Feb 26, 2013 at 2:03
  • 1
    @Karan -Oooh, interesting. I never thought to test until your comment, but on Vista, I get the same error message if ComSpec is defined, but does not point to a valid executable. My CMD session crashes if ComSpec is not defined at all.
    – dbenham
    Feb 26, 2013 at 2:11
  • Great answer, thanks! Solved the problem. I'd upvote you if I had enough rep.
    – marcush
    Feb 26, 2013 at 2:13
  • 1
    @Karan, I modified the answer to reflect your discovery. Thanks.
    – dbenham
    Feb 26, 2013 at 2:15
  • you have here the default ComSpec value: "COMSPEC=C:\\WINDOWS\\system32\\cmd.exe" , take from stackoverflow.com/questions/2276483/…
    – higuita
    Dec 11, 2014 at 16:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .