The Windows .Bat Variable Quirk That Cost Us an Hour

Variables in the Windows CLI have an interesting property that makes how you set them important

We had a bit of fun at work today, trying to figure out why on earth 3GB of seemingly junk data had been copied into a folder my colleague was working in.

Jack had been trying to copy a single file called %file% from %TEMP% to a folder we’ll call %destination%. With the rest of the unnecessary code stripped away, this is essentially what he had:

Seems… pretty normal right? So where was all this junk coming from? Closer inspection of the files didn’t exactly give any helpful clues; it consisted of odd .html files, some small gifs and even the Java 7 installation file.