<pre><code class="lang-auto">FOR /F "tokens=* USEBACKQ" %%F IN (command) DO (
SET var=%%F
)
ECHO %var%
</code></pre>
<p>I always use the USEBACKQ so that if you have a string to insert or a long file name, vous pouvez utiliser your double quotes without screwing up the command.</p>
<p>Now if your output will contain multiple lines, vous pouvez do this</p>
<pre><code class="lang-auto">SETLOCAL ENABLEDELAYEDEXPANSION
SET count=1
FOR /F "tokens=* USEBACKQ" %%F IN (command) DO (
SET var!count!=%%F
SET /a count=!count!+1
)
ECHO %var1%
ECHO %var2%
ECHO %var3%
ENDLOCAL
</code></pre>