 <p>Do you really use command <code>dir</code> in your batch file or another command, a command which itself is enclosed in double quotes because of a space in path or has a parameter in double quotes?</p> <p>If the output of a command should be processed within the loop and the command itself must be specified in double quotes or at least one of its parameters, the following syntax using back quotes is required:</p> <pre><code>for /f "usebackq delims=" %%a in (`"command to run" "command parameter"`) do echo %%a </code></pre> <p>An example:</p> <pre><code>for /f "usebackq delims=" %%a in (`dir "%CommonProgramFiles%"`) do echo %%a </code></pre> <p><code>%CommonProgramFiles%</code> references the value of environment variable <strong>CommonProgramFiles</strong> which is a directory path containing usually spaces. Therefore it is necessary to enclose the parameter of command <code>dir</code> in double quotes which requires the usage of <code>usebackq</code> and back quotes after the opening and before the closing round bracket.</p> <p>Further I suggest to look on value of environment variable <strong>PATH</strong>. There are applications which add their program files directory to <strong>PATH</strong> during installation, but not by appending the directory to end of the list of directories, but by inserting them at beginning. That is of course a bad behavior of the installer of those applications.</p> <p>If you call in your batch file standard Windows commands not located in cmd.exe, but in Windows system directory which is usually the first directory in <strong>PATH</strong>, like the command <code>find</code>, and the installed application by chance has also an executable with same name in the program files directory of the application, the batch file might not work on this computer because of running the wrong command.</p> <p>It is safer to use instead of just <code>find</code> in a batch file <code>%SystemRoot%\system32\find.exe</code> to avoid problems caused by bad written installer scripts of applications modifying the <code>PATH</code> list on wrong end.</p>