"Input line is too long" error in BAT File

WindowsBatch File

Windows Problem Overview


I am having a problem executing a bat file. After some time running I get the "input line is too long" error.

The structure of the bat file is simple. There is a main bat file that calls 10 other bat files that are responsible for updating data of my system modules. In the updating data bat files there are lot of calls for a command(.cmd file) of my system that is responsible for updating the data through some calculations.

The point is, when the process was running in a Windows 2003 Server it was ok. No errors.

Then, when it was upgraded to Windows 2008 Server, I execute the main bat file, several hours later I got the "Input line is too long" error. I can't even execute any command included in the updated data bats manually in that cmd window. But if I close the cmd window and open a new one I can execute the commands without errors.

Anybody had the same problem? Or a solution?

Thanks in advance.

Windows Solutions


Solution 1 - Windows

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.

Solution 2 - Windows

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.

Solution 3 - Windows

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

Solution 4 - Windows

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. :)

Solution 5 - Windows

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.

Solution 6 - Windows

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

Solution 7 - Windows

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.

Solution 8 - Windows

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.

Solution 9 - Windows

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

Solution 10 - Windows

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

Solution 11 - Windows

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCarlos GrossiView Question on Stackoverflow
Solution 1 - WindowsOkkenatorView Answer on Stackoverflow
Solution 2 - WindowsJim BethancourtView Answer on Stackoverflow
Solution 3 - WindowsAmol PatilView Answer on Stackoverflow
Solution 4 - WindowsChrisView Answer on Stackoverflow
Solution 5 - WindowsJames HoldernessView Answer on Stackoverflow
Solution 6 - WindowsRishi PollaiView Answer on Stackoverflow
Solution 7 - WindowsSriharsha g.r.vView Answer on Stackoverflow
Solution 8 - Windowsixe013View Answer on Stackoverflow
Solution 9 - WindowsHossam HousseinView Answer on Stackoverflow
Solution 10 - WindowsBgBgBgBsBsBsView Answer on Stackoverflow
Solution 11 - Windowssg_manView Answer on Stackoverflow