Allowing Input within For Loop
- This topic has 11 replies, 3 voices, and was last updated 9 years, 8 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.
Home › Forums › Scripting › DOS Command Shell › Allowing Input within For Loop
Hello,
I’m trying to log specific output of a program “cdpr.exe”, to a file. The issue is, that the cdpr program requires a couple input commands. How can I allow this within the following batch file, and still create my txt file for logging the specific output?
@echo on & SETLOCAL & Title CDPR
SET “sProgram=Cdpr.exe”
SET “sResults=2xUsers.txt”
IF NOT exist “%sProgram%” goto :ERROR
FOR /F “delims=” %%A IN (‘%sProgram% ^| findstr /b /i /c:”value:”‘) DO (
REM ##trim the incipient spaces of %%B and set the value to %%C
FOR /F “tokens=*” %%C IN (“%%B”) DO (
echo %%C >> %sResults%
)
)
:ERROR
echo There was an error in the path…
goto:eof[/CODE][CODE]@echo on & SETLOCAL & Title CDPR
SET “sProgram=Cdpr.exe”
SET “sResults=2xUsers.txt”
IF NOT exist “%sProgram%” goto :ERROR
FOR /F “delims=” %%A IN (‘%sProgram% ^| findstr /b /i /c:”value:”‘) DO (
REM ##trim the incipient spaces of %%B and set the value to %%C
FOR /F “tokens=*” %%C IN (“%%B”) DO (
echo %%C >> %sResults%
)
)
:ERROR
echo There was an error in the path…
goto:eof[/CODE]
You must be logged in to reply to this topic.
Find out more about our cookie policy here.