I am working on a batch file - yes, I know it owul be preferable to use something else, but this is what I am stuck with.
I am using
SETLOCAL ENABLEEXTENSIONS
to make sure DEFINED will be able to be used.
SETLOCAL makes it so that any variables defined inside the batch file will only be seen inside the batch file.
Now, when I go to check if an environment variable exists, it works.
If DEFINED ProgramFiles(x86)
But if I make a local variable such as:
SET My_Var=1
It gives me a "syntax is incorrect" error anytime I try to do anything besides echo the variable.
I have tried
IF DEFINED My_Var (do something)
IF "%My_Var%"==1 (do something)
IF %My_Var% (do something)
and a few others.
If I do a @ECHO %My_Var% it returns 1.
I am using
SETLOCAL ENABLEEXTENSIONS
to make sure DEFINED will be able to be used.
SETLOCAL makes it so that any variables defined inside the batch file will only be seen inside the batch file.
Now, when I go to check if an environment variable exists, it works.
If DEFINED ProgramFiles(x86)
But if I make a local variable such as:
SET My_Var=1
It gives me a "syntax is incorrect" error anytime I try to do anything besides echo the variable.
I have tried
IF DEFINED My_Var (do something)
IF "%My_Var%"==1 (do something)
IF %My_Var% (do something)
and a few others.
If I do a @ECHO %My_Var% it returns 1.