3

I'm using a file with a huge number of SET for variables. After certain line, those set are not working. It seems there's a limit for the number of variables, is that correct? Is there any way I can avoid that limitation?

Thank you.

Raúl García
  • 315
  • 3
  • 17

1 Answers1

0

There are two (2) limits at work here. The first is the limit on a single variable imposed by the maximum length of a cmd.exe command line. The second is the total size of the environment which, on most current systems, is about 32 KiB. See https://blogs.msdn.microsoft.com/oldnewthing/20100203-00/?p=15083 for more details.

lit
  • 14,456
  • 10
  • 65
  • 119
  • 1
    The overall 32 KiB limit was true up to Windows XP I think, but it does *no longer* apply since Windows Vista! the length of a command line and therefore also the length of a variable value is limited to 8 KiB since Windows XP, and it was 2 KiB in former Windows versions... – aschipfl May 05 '16 at 16:54
  • 2
    There is no 32 KiB limit on Windows XP as it can be read on [Command shell overview](https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true). This article for Windows XP contains on __note__ at bottom: `The maximum individual environment variable size is 8192 bytes.` and `The maximum total environment variable size for all variables, which includes variable names and the equal sign, is 65,536 KB.` So the memory limit for all environment variables is 64 MiB (= 65536 KiB). I suppose Raúl García exceeds this limit. – Mofi May 05 '16 at 20:38
  • See also [Maximum Length of Command Line String](http://stackoverflow.com/questions/3205027/). – Mofi May 05 '16 at 20:40