What I am doing wrong here please? I want to make a windows batch file
that will call an exe
, passing in some arguments and assign the return value to a variable. I have tried lots of different variations of the following but I cant make it work.
SET EXE="path\to\exe"
SET TARGET_FILE="path\to\file\to\be\read\by\exe"
for /f %%i in (%EXE% -arg1 %TARGET_FILE%) do set VAR=%%i
ECHO %VAR%
PAUSE
What am I missing? In case it matters, the two paths above will probably contain spaces, line C:\Program Files\etc
.
The following batch file should work. I have not tested, let me know if it does not.
SET EXE="path\to\exe"
SET TARGET_FILE="path\to\file\to\be\read\by\exe"
for /f "delims=" %%i in ('"%EXE% -arg1 %TARGET_FILE%"') do (
echo %%i
)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments