Contents of multiline file as command line parameters

I have filename (parameters.txt) as input parameter. It is multiline text file containing parameters, quoted when needed
E.g.

"Parameter 1"
"Parameter 2"
Parameter3
etc.

I need a batch to provide them to some executable
I.e.
some_executable.exe "Parameter 1" "Parameter 2" Parameter3 ...

It would be preferable if solution won't require temporary files and won't rely on external commands. Target OS is stripped down, even "find" is missing.
LVL 5
The_Blasted_OneAsked:
Who is Participating?
 
oBdAConnect With a Mentor Commented:
Try the batch script below; the single parameters in your text file need to be quoted as required by the application (in all likelihood every argument containing a space will need to be quoted):
@echo off
setlocal enabledelayedexpansion
set ParaFile=parameters.txt
set ParaString=
for /f "delims=" %%a in ('type "%ParaFile%"') do set ParaString=!ParaString! %%a
some_executable.exe %ParaString%

Open in new window

0
 
The_Blasted_OneAuthor Commented:
Thanks, works like a charm.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.