Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
606 views
in Technique[技术] by (71.8m points)

windows xp - Line length limit in xp batch file?

When running long command in .bat file (say 300 characters length)

for example:

Some_exe "C:/Documents and Settings/Some user/Some folder1/Some folder2/Some folder3/Some folder4 ... -Some_exe_arg1="arg 1 name" -Some_exe_arg2="arg 2 name" -Some_exe_arg3="arg 3 name"  

Is there a limit on the line size CMD.exe can process? Should i use .CMD or .BAT? Is there any way i can overcome this limitation?

Thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

All versions of Windows from XP onward support a maximum batch line length of 8191 bytes: http://support.microsoft.com/kb/830473

Often times executables get around the command line length limit by allowing for parameter values to be specified in a file. For example, FINDSTR has a /G:filename option that specifies the name of a file that contains search strings.

There is no difference between .BAT vs .CMD with regard to line length. In fact, there is almost no difference between them at all: https://stackoverflow.com/a/148991/1012053. (Note - most of the comments questioning the accuracy of the linked answer predate the most recent edited version of the answer. The linked answer is now correct.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...