Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Input line is too long" error in BAT File

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.

like image 888
Carlos Grossi Avatar asked May 29 '13 18:05

Carlos Grossi


People also ask

What does @echo off do in Bat?

@echo off prevents the prompt and contents of the batch file from being displayed, so that only the output is visible. The @ makes the output of the echo off command hidden as well.

What does %% bat mean?

%%a refers to the name of the variable your for loop will write to. Quoted from for /? : FOR %variable IN (set) DO command [command-parameters] %variable Specifies a single letter replaceable parameter. (set) Specifies a set of one or more files.

What is GEQ in batch file?

GEQ is a 'Greater Than or Equal To' comparison operator for the IF command. Example. C:\> If 25 GEQ 50 ECHO smaller. C:\> If "5" GEQ "444" ECHO smaller.


2 Answers

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.

like image 111
Okkenator Avatar answered Oct 02 '22 22:10

Okkenator


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.

like image 45
Jim Bethancourt Avatar answered Oct 02 '22 22:10

Jim Bethancourt