Windows – “Input line is too long” error in BAT File

batch-filewindows

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.

Best Answer

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.