Faire un test sur une variable

Faire un test sur une variable - Shell/Batch - Programmation

Marsh Posté le 29-07-2004 à 14:47:02    

J'aimerai réaliser une commande si une variable a une certaine valeur.
Voici mon script mais il ne fonctionne pas :

Code :
  1. set agence=bordeaux
  2. if %agence%=bordeaux call z:\_script.bat
  3. else goto suite
  4. :suite


Je me plante où :??:

Reply

Marsh Posté le 29-07-2004 à 14:47:02   

Reply

Marsh Posté le 29-07-2004 à 14:56:35    

http://www.robvanderwoude.com/index.html
http://www.robvanderwoude.com/errorlevel.html


Message édité par jagstang le 29-07-2004 à 14:56:51

---------------
What if I were smiling and running into your arms? Would you see then what I see now?  
Reply

Marsh Posté le 29-07-2004 à 15:02:18    

if %agence%=="bordeaux"
par contre je crois pa ke else soit possible en batch

Reply

Marsh Posté le 29-07-2004 à 15:19:54    

Merci j'ai trouvé grace à vous :)
En fait il faut passer par une négation :

Code :
  1. set agence=bordeaux
  2.  
  3. if not %agence%=bordeaux goto suite
  4. call z:\_script.bat
  5.    
  6.   :suite

Reply

Marsh Posté le 29-07-2004 à 15:34:36    

Ok le else n'est donc pa possible en batch

Reply

Marsh Posté le 30-07-2004 à 19:47:44    

Le ELSE existe en batch, il suffit de faite :
 
IF /?
 
Pour le voir

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed