msdos script: environment variable in IF statement

I just saw that the back up script I described earlier was partially not working, because the environment variables used inside the IF statement are replaced with their value as soon as the script reach the IF (same goes for a FOR statement, see for example this link describing the issue).

So when an variable is accessed and modified from within a IF statement of FOR loop, it needs to be accessed as !MY_VARIABLE! instead of %MY_VARIABLE%.
You still need to enable this behaviour in top of your script with
setlocal ENABLEDELAYEDEXPANSION

Tags: , ,

2 Responses to “msdos script: environment variable in IF statement”

  1. [...] this script was not fully working, now corrected. see details in this post] We are using Subversion as resource control for our (flash) projects, and we recently though we [...]

  2. DAVE says:


    CheapTabletsOnline.Com. Canadian Health&Care.Special Internet Prices.Best quality drugs.No prescription online pharmacy. No prescription drugs. Order pills online

    Buy:Lipothin.Wellbutrin SR.Lasix.Cozaar.Female Cialis.Aricept.Female Pink Viagra.SleepWell.Zocor.Advair.Benicar.Buspar.Ventolin.Zetia.Seroquel.Prozac.Acomplia.Amoxicillin.Nymphomax.Lipitor….

Leave a Reply