?
Solved

Contents of multiline file as command line parameters

Posted on 2009-12-29
2
Medium Priority
?
463 Views
Last Modified: 2012-05-08
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.
0
Comment
Question by:The_Blasted_One
2 Comments
 
LVL 85

Accepted Solution

by:
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

0
 
LVL 5

Author Closing Comment

by:The_Blasted_One
ID: 31671044
Thanks, works like a charm.
0

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