Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Maximum line length in a batch file...

1,625 views
Skip to first unread message

KILOWATT

unread,
Sep 11, 2005, 12:47:13 PM9/11/05
to
Hi thanks to read.
I've read on different web sites (including the MS knowledge base) something
that applies to ms-dos that is included with Win98SE that goes more or less
like this: "Each
batch file line does have a limit, however. Any batch file line exceeding
127 bytes is truncated at 127 bytes before it is processed."

However in a test, i could rename a text file that is nine directories deep,
with a REN command line totalizing 285 characters!
Other command like DEL, SORT, COPY works ok too. I would like some replies
to help me clear-up this point.


--
Alain(alias:Kilowatt)
Montréal Québec
PS: 1000 excuses for grammatical errors or
omissions, i'm a "pure" french canadian! :-)
(If replying also by e-mail, remove
"no spam" from the adress.)


William Allen

unread,
Sep 11, 2005, 3:37:41 PM9/11/05
to
"KILOWATT" <kilowatt"nospam"@softhome.net> wrote in message

> Hi thanks to read.
> I've read on different web sites (including the MS knowledge base) something
> that applies to ms-dos that is included with Win98SE that goes more or less
> like this: "Each
> batch file line does have a limit, however. Any batch file line exceeding
> 127 bytes is truncated at 127 bytes before it is processed."
>
> However in a test, i could rename a text file that is nine directories deep,
> with a REN command line totalizing 285 characters!
> Other command like DEL, SORT, COPY works ok too. I would like some replies
> to help me clear-up this point.

In Windows 95/98, typing commands in immediate mode (at the
command prompt), you can use 127 characters by default.

If you configure AUTOEXEC.BAT and CONFIG.SYS correctly, you can
use upto 255 characters at the command prompt, and 1024 characters
in a Batch command line.

In AUTOEXEC.BAT, assuming you are using DosKey, add:

:: Load doskey, handy if any DOSsing around is required
LH doskey /bufsize:1024 /line:255 /insert> NUL

In CONFIG.SYS, assuming C:\WINDOWS is your Windows folder, you
need a SHELL line to reset line length to 255 (/u switch). In the following
I also explicitly use the /L switch for internal Batch lines of 1024
characters (not strictly needed, I seem to recall):

; 4096 bytes environment space; 255 character command line,
; and internal command line length of 1024 characters
SHELL=C:\WINDOWS\command.com C:\WINDOWS /e:4096 /p /u:255 /l:1024

Note that if you use DosKey, you must configure it to match the long
lines you specify in the SHELL command, or it may override the
SHELL command.

There is a further limitation, regardless of the settings above. A command
line cannot have more than 64 tokens, where a token means the smallest
logical syntactic unit in terms of which a line is parsed. The 64
token limit is explained in detail in our Batch Course (Lesson 20,
see detailed explanation and example following Exercise 17).
Index to Lessons: http://www.allenware.com/icsw/icswidx.htm

(These comments don't apply to Windows 2000/XP where the limits
are far higher).

--
William Allen
Free interactive Batch Course http://www.allenware.com/icsw/icswidx.htm
Batch Reference with examples http://www.allenware.com/icsw/icswref.htm
From email address not checked. Contact us at http://www.allenware.com/


Auric__

unread,
Sep 12, 2005, 1:13:01 AM9/12/05
to
On Sun, 11 Sep 2005 20:37:41 +0100, William Allen wrote:

> LH doskey /bufsize:1024 /line:255 /insert> NUL

Just curious, why redirect to nul? If it's in autoexec, it's likely to
already have 'echo off' if the user wants it, right?
--
auric dot auric at gmail dot com
*****
I am not young enough to know everything.

William Allen

unread,
Sep 12, 2005, 3:17:14 AM9/12/05
to
"Auric__" wrote in message

> On Sun, 11 Sep 2005 20:37:41 +0100, William Allen wrote:
>
> > LH doskey /bufsize:1024 /line:255 /insert> NUL
>
> Just curious, why redirect to nul? If it's in autoexec, it's likely to
> already have 'echo off' if the user wants it, right?

It's cut-and-paste from my own AUTOEXEC.BAT, where I tend to
redirect everything to NUL as a matter of routine, whether or not
a particular command that I happen to be using generates STDOUT
in the current version of it. For example, this enables me to use a
simple Search/Replace to write everything to a log file for diagnostic
purposes.

I don't worry about minimising the number of characters in Batch files.
There were also detailed comments for each line - again that's because
they happened to be cut-and-paste from my own configuration files.

foxidrive

unread,
Sep 12, 2005, 8:01:34 AM9/12/05
to
On Mon, 12 Sep 2005 08:17:14 +0100, William Allen wrote:

> "Auric__" wrote in message
>> On Sun, 11 Sep 2005 20:37:41 +0100, William Allen wrote:
>>
>>> LH doskey /bufsize:1024 /line:255 /insert> NUL
>>
>> Just curious, why redirect to nul? If it's in autoexec, it's likely to
>> already have 'echo off' if the user wants it, right?
>
> It's cut-and-paste from my own AUTOEXEC.BAT, where I tend to
> redirect everything to NUL as a matter of routine

You lose a file handle by doing so to a TSR, going from memory.

ras...@highfiber.com

unread,
Sep 12, 2005, 11:23:37 AM9/12/05
to


C:\>ver /r

MS-DOS Version 6.22
Revision A
DOS is in low memory

C:\>files
# Filename Size Attr cRef Owner Cluster, DD, DPB
- -------- ---- ---- ---- ----- ----------------

[SFT @ 0118:00CC -- 5 files]
0 AUX . 0 0000 3 8E71 DEV 0070:0035 0
1 CON . 0 0000 9 8E71 DEV 0070:0023 0
2 PRN . 0 0000 3 8E71 DEV 0070:0047 0

[SFT @ 0B8E:0000 -- 3 files]

C:\>doskey > nul

C:\>files
# Filename Size Attr cRef Owner Cluster, DD, DPB
- -------- ---- ---- ---- ----- ----------------

[SFT @ 0118:00CC -- 5 files]
0 AUX . 0 0000 4 8E71 DEV 0070:0035 0
1 CON . 0 0000 11 8E71 DEV 0070:0023 0
2 PRN . 0 0000 4 8E71 DEV 0070:0047 0
3 NUL . 0 0000 1 0E32 OR DEV 0118:0048 0

[SFT @ 0B8E:0000 -- 3 files]

C:\>doskey /reinstall > nul

C:\>doskey /reinstall > nul

C:\>doskey /reinstall > nul

C:\>files
# Filename Size Attr cRef Owner Cluster, DD, DPB
- -------- ---- ---- ---- ----- ----------------

[SFT @ 0118:00CC -- 5 files]
0 AUX . 0 0000 7 8E71 DEV 0070:0035 0
1 CON . 0 0000 17 8E71 DEV 0070:0023 0
2 PRN . 0 0000 7 8E71 DEV 0070:0047 0
3 NUL . 0 0000 1 0E32 OR DEV 0118:0048 0
4 NUL . 0 0000 1 0E32 OR DEV 0118:0048 0

[SFT @ 0B8E:0000 -- 3 files]
5 NUL . 0 0000 1 0E32 OR DEV 0118:0048 0
6 NUL . 0 0000 1 0E32 OR DEV 0118:0048 0

C:\>

---------------------------------------------------------------
MS-DOS 6.22, COMMAND.COM, no TSRs or device drivers loaded before
starting. "files" is the FILES.EXE utility from Undocumented DOS,
Second Edition, by Schulman et al. "OR" after the owner segment
indicates that FILES.EXE thinks a handle is orphaned.

--
Charles Dye ras...@highfiber.com

out...@citynet.net

unread,
Sep 12, 2005, 3:46:54 PM9/12/05
to
"Just curious, why redirect to nul? If it's in autoexec, it's likely to
already have 'echo off' if the user wants it, right?"

It depends on goals. Some programs echo to screen some messages
regardless of the echo setting. Sending all output to nul takes care of
that also. Even so some programs demand attention by even bypassing both
the echo off and nul approaches.

0 new messages