Reputation: 33607
The following script
cmd /C ""set PATH=nasm\;%PATH%" & "echo %PATH%""
Only prints this:
The input line is too long.
The input line is too long.
Why? How can I fix this?
P. S. This works:
cmd /C "echo %PATH%"
And this doesn't:
cmd /C ""echo %PATH%""
Upvotes: 7
Views: 24471
Reputation: 608
Had the same problem and it was actually mis-reported error in the executable name. Had this
"C:\Java\jdk1.8.0_151"\bin\java"
instead of this
"C:\Java\jdk1.8.0_151\bin\java"
Upvotes: 0
Reputation: 5514
The OP's problem differed slightly from mine, but I also had The input line is too long
error in a very basic script for no obvious reason.
In my case, the reason that it was not obvious is that I had earlier corrupted my environment by recursively setting my Path until it exceeded the permissible size and then I had fixed the issue before attempting to diagnose the error.
Restarting the command prompt was sufficient in this case to get a fresh Path.
To test if you might have done something like this, just display your environment variables by running set
with no arguments. In my case, it showed the recursively set Path (much longer than shown here, but you see the repeating parts):
C:\dev_build>set
...
Path=C:\qnx660\host\win32\x86\usr\bin;C:\qnx660\.qnx\bin;C:\qnx660\jre\bin;C:\qnx660\host\win32\x86\usr\bin;C:\qnx660\.qnx\bin;C:\qnx660\jre\bin;C:\qnx660\host\win32\x86\usr\bin;C:\qnx660\.qnx\bin;C:\qnx660\jre\bin;C:\qnx660\host\win32\x86\usr\bin;C:\qnx660\.qnx\bin;C:\qnx660\jre\bin;C:\qnx660\host\win32\x86\usr\bin;C:\qnx660\.qnx\bin;C:\qnx660\jre\bin;C:\qnx660\host\win32\x86\usr\bin;C:\qnx660\.qnx\bin;C:\qnx660\jre\bin;C:\qnx660\host\win32\x86\usr\bin;C:\qnx660\.qnx\bin;...
...
Any further attempts to do anything to Path gave me The input line is too long
Upvotes: 10
Reputation: 82337
With using two double quotes ""
, the cmd.exe expects a single command.
But a command has a limit of ~250 characters.
But you don't want a command named echo C:\windows\...
.
And your set path=... & echo %path%
can't work, as the percent expansion is done before the line is executed.
This one should work
cmd /v:on /C "set PATH=nasm\;%PATH% & echo ^!PATH^!"
But I can't see any reason why you don't use a code block, perhaps with setlocal
(
setlocal EnableDelayedExpansion
"%VS120COMNTOOLS%..\..\VC\bin\vcvars32.bat"
set "PATH=nasm\;%PATH%"
echo !PATH!
endlocal
)
If you really need to use cmd /c
then it can also contains quotes, but not over multiple commands
cmd /v:on /C ""%VS120COMNTOOLS%..\..\VC\bin\vcvars32.bat" & set PATH=nasm\;%PATH% & echo ^!PATH^!"
Upvotes: 5