I'm looking to echo a piece of text input by the user from a batch file into a text file but I'm having some trouble: Every time the user enters the string and when the batch file closes, the text file is empty, almost like the variable was never set.
@ECHO OFF
SETLOCAL
set /a num=%random% %%100 +1
SET /a nummod2=num %% 2
IF %nummod2% == 0 (
cls
echo Enter some Text!
set /p string=Text:
echo Text="%string%" >> Log.txt
exit
) ELSE (
exit
)
GOTO :EOF