Batch Script ErrorLevel Output
<p>I need help - I am trying to output any ErrorLevel that is 1 or greater into a log file. When I issue the command the log file never get's generated. Any help would be greatly appreciated.</p>

<p>Script:</p>

<pre><code>for /f "delims=" %%i in (C:\_\Restart\Computer.txt) do (
start "%%i" \_\PStools\psexec \\%%i -u Administrator -p Password -i c:\restart.cmd
if not %errorlevel%==0 echo %errorlevel% &gt; error.log
)
</code></pre>

<p>This script allows me to use PSEXEC and issue a restart command to all the computer at once. However several of them fail and I'd like to know which ones fail.</p>

<p>Thanks!</p>

<p>Is this the format I should use?</p>

<pre><code>setlocal EnableDelayedExpansion

for /f "delims=" %%i in (C:\_\Restart\Computer.txt) do (
start "%%i" \_\PStools\psexec \\%%i -u Administrator -p Password -i c:\restart.cmd
if errorlevel 1 echo !errorlevel! &gt; error.log
)
</code></pre>