Home > Mobile >  Converting .ps1 to .bat doesn't cause cmd.exe to hit max character length - but why?
Converting .ps1 to .bat doesn't cause cmd.exe to hit max character length - but why?

Time:09-23

Based on a Truncated Command

CodePudding user response:

  • The 8191-character limit applies to the interactive command line and calls to cmd.exe's CLI (via cmd /c)

  • It does not apply to commands invoked from batch files - there the limit is close to 32KiB (close to 32,768) characters.

    • However, it still seems to apply selectively to cmd.exe's internal commands, such as echo; by contrast, a call to an external program such as powershell.exe is not affected.

As an aside: as clever as the linked method of converting PowerShell scripts to batch files is, the resulting batch files lack support for arguments, and adding that would be far from trivial.

  • Related