Contents of multiline file as command line parameters

Posted on 2009-12-29
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 82

    Accepted Solution

    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

    LVL 5

    Author Closing Comment

    Thanks, works like a charm.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
    For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now