I just tried to code a simple batch which will help me copy some files with some user-slected options. This batch file exits as soon as it reaches the big if statement
Rem @echo off SETLOCAL ENABLEDELAYEDEXPANSION set /a verifier="true to ok: " :begin echo Welcome to install! echo Y - Install echo N - Remove choice /m "Select Y/N : " if "!errorlevel!"=="1" ( echo Installation: echo Y - Default echo N - Custom choice /m "Select Y/N : " if "!errorlevel!"=="2" ( echo Custom selected goto custom ) else ( xcopy %cd% C:\FPC\ if "%verifier%"=="true" ( echo Install OK! ) else ( echo Installation goes wrong! ) ) echo echo Y - Run now echo N - Don't run choice /m "Select Y/N :" if "!errorlevel!"=="1" ( echo Run start start.cmd ) else ( echo Don't run ) goto theend ) else ( echo Removal goto remove ) SETLOCAL DISABLEDELAYEDEXPANSION goto theend :remove echo delete something goto theend :custom echo run another batch file goto theend :theend echo the end pause The batch exits immediately after I typed the (Y/N) choice. I guess the problem comes from the big if, but I can't find where is wrong or what I'm missing here. Thank you for your help! Sorry for my bad english.
set /a verifier=true?echoon e.g.REM @echo offand looking at screen output.set /a verifier=truewill always setverifierto0. You can doset verifier=trueand test withif "%verifier%"=="true"andif not "%verifier%"=="true"