1

So I have a variable "Var" I want to echo its content into a text file, now this doesn't work

set Var=1
echo %Var%>text.txt

if you add space like this, it'll work :

set Var=1
echo %Var% >text.txt

How can I echo just "1" without a space after ?

Fienda
  • 87
  • 1
  • 3
  • 9

1 Answers1

0

this is because it takes 1 for the out stream which is under 1 for the batch files. Try this:

(echo(%Var%)>text.txt

or

@echo off

setlocal enableDelayedExpansion

set var=1
echo !var!>text.txt

or

@echo off

set var=1

1>test.txt  echo %var%
npocmaka
  • 55,367
  • 18
  • 148
  • 187