Guillaume S
Guillaume S

Reputation: 1490

Windows Batch: command result as command parameter

I have a curstom command that is an query language interpretor. And the file contains some queries to execute.

I want to execute this custom command by passing the whole file content as parameter with a single command.

For exemple somethink like :

myCustomCmd %type params.txt%

Is it possible ?

Thanks

Upvotes: 0

Views: 59

Answers (1)

Magoo
Magoo

Reputation: 79957

for /f "usebackq delims=" %%a in ("params.txt") do myCustomCmd %%a

should draw that line from the file and use it as a parameter for you command.

Had you given us a context, I'd be able to provide more information.


Ah - you want "the entire file content" as the parameter - a requirement you edited-in five minutes after I'd posted this response...

@echo off
setlocal enabledelayedexpansion
set "params="
for /f "usebackq delims=" %%a in ("params.txt") do set "params=!params! %%a"
myCustomCmd %params%

That should fix the problem - in the absence of an example params.txt file.

Upvotes: 1

Related Questions