Batch file not keeping variables <p>Why doesn't the below batch file keep variables when CMD.exe terminates</p> <pre><code>@echo off cmd /c "set var=hi" if defined var (echo var is defined ("var=%var%")) else (echo var isn't defined) pause exit </code></pre> <p>Is there any way to use CMD /c, whilst keeping variables? and why doesn't CMD /c keep variables?</p>