[CONT] 8192

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: [CONT] 8192

#16 Post by Cleptography » 15 Jun 2011 19:19

You are right as of right now there is no direct way to surpass this restriction and there never will be using batch itself,
because of the cmd code itself. The only options are workarounds and external utilities. I guess all this example does is
show a cheap workaround that could be used to create temp scripts to execute beyond the limitation but still stay within
the main script...kind of... Nothing short of rewriting cmd would properly and effectively correct this issue, I guess that is
what powershell is for. :P

allal
Posts: 34
Joined: 04 Jun 2011 05:49

Re: [CONT] 8192

#17 Post by allal » 16 Jun 2011 05:31

Cleptography wrote: I guess that is
what powershell is for. :P


yes powershell variable,arguments length can reach up to 2 billion character

what a difference

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: [CONT] 8192

#18 Post by Cleptography » 18 Jun 2011 01:41

Ok so you can't set a variable beyond 8192 bytes using

Code: Select all

set var=8192bytes

but you can...

Code: Select all

@echo off
call :label some string beyond 8192 bytes
exit /b
:label
echo;%*
goto :eof

...or some command...

Code: Select all

call :label for /L %%%%- in (1,1,10) do echo;%%%%-
exit /b
:label
%*
goto :eof

Code: Select all

set PC=%%%%%
set CMD=echo;%PC%A

call :label1 for /L %PC%A in (1,1,10) do %CMD%
exit /b

:label1
%*
goto :eof

Maybe I am wrong here but technically %* holds the value from the call label so would %* be a variable of sorts?
Wouldn't there be a way to build functions and macros around this formula?
I didn't test the limitations to in depth but it seems to cause some problems around 200k chars.
Of course ^ has its strange results.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: [CONT] 8192

#19 Post by Cleptography » 18 Jun 2011 21:59

So as I continue on this we can use a for to transfer values to x as you can see we can pass a large amount of parameters to x I am working on building a macro example with 10000 bytes to pass to x. I am sure with call to things slow down a bit but not by much, and I can pass arguments beyond 8k which will always default to the value of %1.

Code: Select all

    @echo off
    @setlocal

    :test_1
    set PC=%%%%%
    set CMD=echo;%PC%A

    call :label1 "for /L %PC%A in (1,1,10) do %CMD%" "for /L %PC%A in (1,1,20) do %CMD%"^
    "for /L %PC%A in (1,1,30) do %CMD%" "for /L %PC%A in (1,1,40) do %CMD%"^
    "for /L %PC%A in (1,1,50) do %CMD%" "for /L %PC%A in (1,1,60) do %CMD%"^
    "for /L %PC%A in (1,1,70) do %CMD%" "for /L %PC%A in (1,1,80) do %CMD%"^
    "for /L %PC%A in (1,1,90) do %CMD%" "for /L %PC%A in (1,1,100) do %CMD%"^
    "for /L %PC%A in (1,1,110) do %CMD%" "for /L %PC%A in (1,1,120) do %CMD%"^
    "for /L %PC%A in (1,1,130) do %CMD%" "for /L %PC%A in (1,1,140) do %CMD%"^
    "for /L %PC%A in (1,1,150) do %CMD%" "for /L %PC%A in (1,1,160) do %CMD%"^
    "for /L %PC%A in (1,1,170) do %CMD%" "for /L %PC%A in (1,1,180) do %CMD%"^
    "for /L %PC%A in (1,1,190) do %CMD%" "for /L %PC%A in (1,1,200) do %CMD%"^
    "for /L %PC%A in (1,1,210) do %CMD%" "for /L %PC%A in (1,1,220) do %CMD%"^
    "for /L %PC%A in (1,1,230) do %CMD%" "for /L %PC%A in (1,1,240) do %CMD%"^
    "for /L %PC%A in (1,1,250) do %CMD%" "for /L %PC%A in (1,1,260) do %CMD%"^
    "for /L %PC%A in (1,1,270) do %CMD%" "for /L %PC%A in (1,1,280) do %CMD%"^
    "for /L %PC%A in (1,1,290) do %CMD%" "for /L %PC%A in (1,1,300) do %CMD%"
    exit /b

    :label1
    for /f "tokens=*" %%x in ("%~1") do (
       if [%%x]==[] (goto :eof
       ) else echo;%%x
    )&& shift && goto :label1

Of course storing the value %1 in x only works for storing the command and not execution instead we
use

Code: Select all

:label1
if ["%~1"]==[""] goto :eof
%~1
shift
goto :label1

Post Reply