Вопрос

Having a problem with an If statement in a batch file. I have several scripts, one will set a value to variable and store it to a text file to be read by another script. The value is either yes or no. That part works. When the next script executes, it first reads the line from the txt file and stores the value to a variable. That part works, I can echo the variable and see that it reads the line and stores it to the variable. Now, the next section is suppose to evaluate the variable and based on the result the script will either continue or exit. for some reason it always exits. Below is sample of the statement:

::****Check Value******
set /p _xexit=<xclean.txt
Echo %_xexit%
if %_xexit%=yes (
goto skip3
) else (
::CODE TO EXECUTE IF %_xexit%=no starts here
code
::AFTER THIS CODE EXECUTES, SCRIPT WILL EXIT

::My skip3
:skip3
echo "Exit Called"
wait
Exit
Это было полезно?

Решение

You have to double the =

if "%_xexit%"=="yes" 
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top