I think all you need to know about is ERRORLEVEL.
If you use call :label <params>
, you can break up the logic in ways you aren't doing here. There are ways to do it without the call :label
syntax but I prefer this method.
After running robocopy, you need to look at the ERRORLEVEL variable to determine success or not. You could ALSO simply check if the file is there after the robocopy line.
Something like this:
@echo off
Set SalidaArchivo=%TEMP%\RobocopyResults.txt
for /F "tokens=*" %%i in (Maquinas_log.txt) do call :RoboCopyFileWithResults "%%i"
goto :EOF
:: Note: goto :EOF arriba es "volver a la función de llamada".. en este caso saldrá
:: Note: goto :EOF above means "return to the calling function" which in this case will exit the batch.
:: ----------------------------------------------------------------
:RoboCopyFileWithResults
Set ServidorNombre=%~1
robocopy.exe "E:\HERRAMIENTAS\SCRIPTS\ActualizarFirmas" \\%%i\c$\temp firmas.exe /R:1 /W:1
echo %ServidorNombre%=%ERRORLEVEL% >>%SalidaArchivo%
goto :EOF
:: Note: goto :EOF arriba es "volver a la función de llamada"
:: Note: goto :EOF above means "return to the calling function"