ChatGPT解决这个技术问题 Extra ChatGPT

"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.

Do you pass file paths as parameters? If yes , you can use short names.
There is nothing you can do to advance the input line over the lenght of the specification by Microsoft. Write your parameters in a parameter file. Short file names on NTFS might be disabled.
Yes, I pass the file path as parameters but why was working on Windows 2003 server and not working with the 2008?? The bat file is the same.
Look at the specs. It may vary.
closing a console window and opening new one helped in my case

O
Okkenator

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 had these problems in Visual Studio custom build step/event, updated path variable in custom build step with "set PATH=my_bin_dir;%path%" and that solved the problem.
It's always a safeguard to SETLOCAL in your cmd scripts.
J
Jim Bethancourt

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.


A
Amol Patil

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


This solved my kafka problem :)
C
Cà phê đen

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


my issue resolved after removing quotes from both start and end of line
J
James Holderness

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.


s
shirley

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

https://i.stack.imgur.com/J6MsA.jpg

https://i.stack.imgur.com/rz3zF.jpg


ha! I came here because I was getting this error in Kafka. how did you know! :)
B
BgBgBgBsBsBs

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

S
Sriharsha g.r.v

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.


i
ixe013

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:

Use an hexadecimal editor Look at how spaces are represented Search and replace your representation

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


H
Hossam Houssein

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


Thanks dude it solved my problem related to convert oracle form to XML by using frmf2xml.bat.
s
sg_man

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.


Yes, it is the same issue. You could consider it a workaround to the fact that the vcvarsall.bat file does not guard against multiple calls to itself. I added the guard in my solution.