powershell - What is the maximum length of the -ArgumentList parameter of the Start-Process cmdlet -
i'd use start-process
call programm ps , pass bunch of arguments call said program should process in background.
it might happen, total list of supplied arguments program might hundreds (something 200-300 in total), each again string
of 32 bytes length. i've tried find out maximum length of -argumentlist
couldn't find reference far.
i doubt run problems amount of arguments supply, did bug me, how many arguments or how long in total might -argumentlist
parameter be?
combined length of 8191 characters, maybe. or maybe depends on program you're running.
source: trial , error (windows 8.1 / psv4):
start-process -filepath cmd -argumentlist (@('/k','echo 1') + (2..1852)) # works start-process -filepath cmd -argumentlist (@('/k','echo 1') + (2..1853)) # doesn't work
around 6769 triggers exception:
ps c:\> start-process -filepath cmd -argumentlist (@('/k','echo 1') + (2..6768)) start-process : command cannot run due error: filename or extension long. @ line:1 char:1 + start-process -filepath cmd -argumentlist (@('/k','echo 1') + (2..676 ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : invalidoperation: (:) [start-process], invalidoperationexception + fullyqualifiederrorid : invalidoperationexception,microsoft.powershell.commands.startprocesscommand
but if shift numbers bit (2..1852|%{$_*100})
fails sooner. suggesting it's not number of arguments matters, string length of combined result.
((@('/k','echo 1') + (2..1852)) -join " ").length # 8160 when works, 8165 when breaks
google 8165 limit cmd
, get:
maximum length of command line string
https://support.microsoft.com/en-gb/kb/830473
on computers running microsoft windows xp or later, maximum length of string can use @ command prompt 8191 characters.
so, either 8191 characters or ... maybe depends on program you're calling.
300 * 32 break that.
but again, if you've got program can handle - start-process appears have no problem array of 1,800 items argument list.
Comments
Post a Comment