batch-file Input and output redirection An Example...

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

@echo off
setlocal
set /p "_myvar=what is your name?"
echo HELLO!>file.txt
echo %_myvar%!>>file.txt
echo done!
pause
type file.txt
endlocal
exit

Now file.txt looks like:

HELLO!
John Smith!

(assuming you typed John Smith as your name.)

Now your batch file's console looks like:

what is your name?John Smith
done!
Press any key to continue...
HELLO!
John Smith!

( and it should exit so quickly that you may not be able to see anything after the prompt Press any key to coninue... )



Got any batch-file Question?