Create a text file using user input from a batch file
Solution 1:
You can use set /p
to ask the user for input:
set /p SomeVar=What is your favourite colour?
echo Favourite colour: %SomeVar%
Solution 2:
This will ask for four values, then print the resulting file to the desktop. It will append to the same file everytime you run this, unless you delete the file.
@echo off
set Output="%USERPROFILE%\desktop"
set /p VarOne=Enter variable one value:
set /p VarTwo=Enter variable two value:
set /p VarThree=Enter variable three value:
set /p VarFour=Enter variable four value:
REM enter your desired output here
echo Variable One = %VarOne% >> %Output%\test.txt
echo Variable Two = %VarTwo% >> %Output%\test.txt
echo Variable Three = %VarThree% >> %Output%\test.txt
echo Variable Four = %VarFour% >> %Output%\test.txt
echo.
echo File has been placed %Output%
pause