xbmc/xbmc — comment on commit 9ed430118886c56e478e9e7fdd308f21f13dcf85
File:  line 0
By Voyager-xbmc:

Microsoft doc provides the answer:

Use setlocal to change environment variables when you run a batch file. Environment changes made after you run setlocal are local to the batch file. Cmd.exe restores previous settings when it either encounters an endlocal command or reaches the end of the batch file.