Actually I want to pas the content of txt file to if condition
I am trying the following
set /p var = < file name
if not %var% == “string” goto x else goto y
But it's not working .
When I check value of var it shows variable not defied
Set %var%
Environment variable %var% not defined
I think you want
to show the current contents of the variable
var
.It may be worth noting that
"%var%"
has to be in quotes. If you leave%var%
without quotes and%var%
containsstring
your statement becomes:if not string == "string" goto x else goto y
now it's working. I was using space in set variable cmd.
set /P someVar=< file.txt
if "%someVar%"=="some text" (echo true) else (echo false)
From what I understood, this is the example to be based on.