When using pipe getting “The filename, directory name, or volume label syntax is incorrect.”

冷暖自知 提交于 2019-12-20 03:24:11

问题


When I run the following command (or any command with a pipe | in it) on my machine:

dir | findstr "Directory"

I get the following message:

The filename, directory name, or volume label syntax is incorrect.

Running dir command or findstr command by themselves works just fine.

The volume label is:

vol
Volume in drive C is OSDisk
Volume Serial Number is 685C-A5B5

The version is:

ver
Microsoft Windows [Version 6.1.7601]


回答1:


As previously mentioned by @dbenham You need to make sure your COMSPEC variable has correct values defined.

It should have the following value:

%SystemRoot%\system32\cmd.exe

You can check it by Right Clicking My Computer-->Properties--->Advanced System Properties-->Environment Variables

If You don't find COMSPEC there, create a new variable by giving the above mentioned value i.e. %SystemRoot%\system32\cmd.exe

Good Luck




回答2:


Check your COMSPEC variable. It should contain the full, absolute path (including file name) to CMD.EXE. Each side of a pipe is executed via a new CMD.EXE thread that is launched via the COMSPEC value.



来源:https://stackoverflow.com/questions/15258695/when-using-pipe-getting-the-filename-directory-name-or-volume-label-syntax-is

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!