Contents of multiline file as command line parameters

Posted on 2009-12-29
Medium Priority
Last Modified: 2012-05-08
I have filename (parameters.txt) as input parameter. It is multiline text file containing parameters, quoted when needed

"Parameter 1"
"Parameter 2"

I need a batch to provide them to some executable
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.
Question by:The_Blasted_One
LVL 85

Accepted Solution

oBdA earned 500 total points
ID: 26142929
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


Author Closing Comment

ID: 31671044
Thanks, works like a charm.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question