-1

I need some assistance. Is it possible to make it so that this code:

@echo off
@title test
(
echo %test%
) >> test.txt
pause

Would have this in "test.txt"

%test%

Instead of this:

ECHO is OFF.

So basically, I wan't to know if you can put a variable in a text document, without the actual variable showing up in the text document. Thanks

Vusho
  • 1
  • 1
    You can escape `%` with another `%`: `echo %%test%%` Not an answer because I"m sure this is answered already. –  Dec 20 '18 at 21:20
  • 2
    Maybe https://stackoverflow.com/q/6828751/1531971 among others. –  Dec 20 '18 at 21:21

1 Answers1

0

ECHO needs a period following the command to treat the following values as not parameters of ECHO itself. This is correct:

echo.%test%

This is asking for trouble:

echo %test%
shawn
  • 383
  • 2
  • 8
  • plain wrong. The dot just don't give an error message, if the variable is empty – Stephan Dec 25 '18 at 22:23
  • No, it doesn't. The dot ensures that, I quote, "treat the following values NOT as parameters of ECHO itself." Here's an example you can try to demonstrate this: `set "test=/?"&echo %test%` vs `set "test=/?"&echo.%test%` – shawn Dec 26 '18 at 02:06