0

I know > and >> redirect a command to a file, but how can I get every line of data from the batch file? I have many commands that echo stuff, but I want just 1 that will echo every single command that's been used in the window to a text document.

Batch file:

@echo off Choice /n /c 12 If %errorlevel%==1 echo hi Etc..

You know what works perfectly? Right click > edit > select all. HOW THE HELL DO I DO THAT IN CODE

0

2 Answers 2

1

Say your batch script is called myScript.bat, then redirect when you call it:

myScript >log.txt

You will want to add CALL if used from within another batch script.

You can do the redirection from within your script if you CALL a main routine:

@echo off
call :main >log.txt
exit /b

:main
rem rest of your code goes here.
Sign up to request clarification or add additional context in comments.

3 Comments

Yeah this kind of works. But I have a whole user-interactive system in my code and I want to get what they already chose in the past
@user3762093 - I suggest you post some simplified code examples to demonstrate your design, and better describe exactly what you are trying to achieve.
Id recommend tracking Down the Snake.bat program It logs all user input and game actions. Have a look through it's code- All the answers to your question are there.
0

You probably looking for the tee command. It allows for writing to both STDOUT and a textfile at the same time.

More info here : http://linux.101hacks.com/unix/tee-command-examples/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.