I'm currently attempting to concatenate my command line arguments with this:
for %%a in (%*) do set "subject=%subject% %%a"
So for example if I run
my.bat subject line here
it should set my subject variable to "subject line here", preserving the spaces. However, currently after the run, my subject variable is set to the last word. I get a subject value of " here."
How to concatenate the command line arguments right?
subjectdoes not have the expected string after the FOR loop, open a command prompt window, runset /?and read all output help pages. There is aforexample very similar to yours on which is explained why delayed expansion must be used to concatenate the strings correct.