BAT 文件中的“输入行太长”错误

我在执行蝙蝠档案时遇到了问题。运行一段时间后,我得到“输入行太长”错误。

Bat 文件的结构很简单。有一个主 bat 文件调用10个其他 bat 文件,这些文件负责更新我的系统模块的数据。在更新的数据 bat 文件中,有许多对命令(。Cmd 文件) ,该文件负责通过一些计算更新数据。

关键是,当进程在 Windows2003Server 中运行时,它是正常的。没有错误。

然后,当它升级到 Windows2008Server 时,我执行主 bat 文件,几个小时后我得到了“ Input line is too long”错误。我甚至不能在 cmd 窗口中手动执行包含在更新数据蝙蝠中的任何命令。但是如果我关闭 cmd 窗口并打开一个新的窗口,我可以在没有错误的情况下执行命令。

有人有同样的问题吗? 或者解决方案?

先谢谢你。

113753 次浏览

There is a Windows knowledge base article on this subject. They don't mention Windows 2008 server, but they did mention the difference in size between other versions of the OS, so it wouldn't be surprising is there was a difference between 2003 and 2008.

As for solutions to the problem, some of their suggestions include:

  • Modify programs that require long command lines so that they use a file that contains the parameter information, and then include the name of the file in the command line.
  • Use shorter names for folders and files.
  • Reduce the depth of folder trees.

You can read the whole article if you want to see what else they have to say, but those were the suggestions that looked most likely to apply to you.

I happened upon this error just now for the first time after running the same set of commands (stop / start an application server) a number of times.

The error stopped when I opened up a new command line and tried the commands from the new command line console.

I have had this same problem when executing a build script in a cmd window. After about 13 times I got that same error. The build script had to make sure that vcvarsall.bat was run so it executed vcvarsall.bat every time.

vcvarsall.bat is not smart enough to only add things to the path if they are not already there so a bunch of duplicate entries were added.

My solution was to add an if defined check on an environment variable which I know is set by vcvarsall.bat...

if not defined DevEnvDir (
call vcvarsall.bat
)

Check your path environment variable after each run and see if it is growing. If it is and there are duplicates, you will need to be smart about adding stuff to the path. There are several ways to be smart about it.

I realize this is pretty old, but the other issue I ran into was having a " at the end of the command I was calling. I was attempting to call:

"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\..\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe""

If you notice, I have two " at the end of the line. This was causing my issues (Notepad++ included it when I typed the quotes). Removed that, all good. Again, may not be your issue, but if anyone else comes seeking info and nothing else works, check this. :)

It can also happen if the spaces in your file (ansi character 0x20) are really non-breaking spaces (I had 0xA0, but yours may vary). This can happen if you copy/pasted from the internet to a UTF-8 aware editor.

The result depends on the current codepage of windows, your editor and such. To fix:

  1. Use an hexadecimal editor
  2. Look at how spaces are represented
  3. Search and replace your representation

I used HxD to search and replace 0xA0 to 0x20.

I ran into this also.

I was trying to run vcvars.bat as others here seem to be trying.

The underlying problem for me seemed to be that my PATH variable was polluted with repeats of an already pretty lengthy path. Fixing up my path seemed to fix the issue for me (in a new terminal, of course). Note that this fix isn't specific to vcvars.bat or anything Visual Studio related.

I'm curious if Cookie Butter's solution is a workaround and the underlying problem is the same.

using CALL several times to run another batch that sets env will increment the value of the var you are setting,hence the error at some point

call set path=some\path;%path%

running the above command in cmd for many times will produce the error

This usually happens due to long path. I have resolved this issue by replacing base path of Kafka from C:\Program Files<Kafka_path> to C:\Kafka

when it's necessary to call vcvarscall.bat multiple times, then:

setlocal
vcvarsall.bat x64
cl xxx.cpp
endlocal


setlocal
vcvarsall.bat x86
cl xxx.cpp
endlocal

I have the same issue to start zookeeper under window. The root cause is due to file path is too long. I relocated the kafka folder to shorter file path. For example : c:/kafka_2.13-2.6.0. then cd to bin/windows and start zookeeper. It works.

Rename the folder name to Kafka . It worked fine for me . Close the cmd and start it again . That will definitely work fine !!

Before : enter image description here

After : enter image description here

This happens due to long path or long name of directory . I have resolved this by renaming the folder name by removing the version from it and placing the folder to c: directory. Example - from = C:\Users\rsola\Downloads\kafka_2.13-3.3.1 to = C:\kafka