samedi 28 novembre 2015

How to use set and if statements in batch files

So i'm trying to make a small batch program with some sets and ifs, seems easy enough right? Apparently, you can't use "set" and "if" like this.

@echo off
setlocal enabledelayedexpansion
cls
set variableTrue EQU 1

Then continue the code and later in the program do this.

If %variableTrue% EQU 1 goto next

Please note I've tried it with exclamation marks as well. With the exclamation marks, it's like it completely ignores the statement, even if it's true it will continue as usual. With the percentage signs, it says very quickly before crashing "1" was not expected at this time. Or something like that, like I said it barely stayed for half a second. I always thought you could do it like this as long as there are no conflicting variables.

Aucun commentaire:

Enregistrer un commentaire