Sunday, April 26, 2009

Note in batch files

There is a tricky difference between commands run in console and commands reside in a batch file. The typical example is the variable definitions. Compare these 2 cases:

Correct in console
: for %i in (*.exe, *.dll) do cmd.exe %i
Correct in batch file: for %%i in (*.exe, *.dll) do cmd.exe %%i

Batch file needs double %.
Special thanks to TechRepublic.