Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;
C:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\;
C:\Programs\MySQL\MySQL Server 5.1\bin;
C:\Programs\Aldec\Active-HDL 9.1\bin;


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?

share|improve this question
up vote 8 down vote accepted

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.

share|improve this answer
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 '13 at 2:03
@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 '13 at 2:11
Great answer, thanks! Solved the problem. I'd upvote you if I had enough rep. – marcush Feb 26 '13 at 2:13
@Karan, I modified the answer to reflect your discovery. Thanks. – dbenham Feb 26 '13 at 2:15
@marcush: one more upvote for you and you can upvote the answer, too. – 0xC0000022L Feb 26 '13 at 2:27

You must log in to answer this question.

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