Someone around the office joked that my blog is turning into "Random Batch File Tips and Tricks." I'll continue that trend with this post...

I recently encountered an environment variable surrounded by exclamation points instead of the usual percent signs. (ie. !MYENVVAR! instead of %MYENVVAR%). It turns out that this is used to delay the expansion of the environment variable until it is actually needed. The first processing step that happens in a statement is to expand all the environment variables.

I was in the process of writing up a big example when I found one on microsoft.com already. Scroll down and click on "What is delayed environment variable expansion?"

http://www.microsoft.com/technet/prodtechnol/Windows2000serv/support/FAQW2KCP.mspx