8

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?

marcush
  • 83

2 Answers2

11

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.

dbenham
  • 11,794
0

For those who has found this answer and have another error: Not enough memory.

Or even a hang on the pipe operator:

whoami /groups | find.exe ""

This is because of an issue with the 65001 code page in the Windows 7: Why find.exe not work in Windows 7?

Solution: Change the code page to something else to workaround it:

chcp 1251

Or use findstr.exe instead:

whoami /groups | findstr.exe /L "..."
Andry
  • 116