I need help with my script below:
It does not continue for the next row of machine.txt If I put the \")\" after \"echo !machine\", it shows the machines inside the machi
You cannot use goto
within the for
body as goto
breaks the for
loop context.
I would place your labelled sections :64bits
and :32bits
into sub-routines and call
them:
@echo off
set server=\\server01\share
dir /B /O %server% | find "i32" | more +2 > 32.txt
FOR /F "tokens=*" %%A in (32.txt) do SET file32=%%A
dir /B /O %server% | find "i64" | more +2 > 64.txt
FOR /F "tokens=*" %%B in (64.txt) do SET file64=%%B
setlocal EnableDelayedExpansion
for /F "tokens=*" %%C in (machines.txt) do (
set "machine=%%C"
echo !machine!
if exist "\\!machine!\c$\Program Files (x86)" (
call :64bits
) else (
if exist "\\!machine!\c$\Arquivos de Programas (x86)" (
call :64bits
) else (
call :32bits
)
)
echo Finished !micro!
)
pause
endlocal
exit /B
:64bits
xcopy /D /Y /F /C %server%\%file64% \\!machine!\c$\
PsExec.exe -d \\!machine! "C:\%file64%" /q
exit /B
:32bits
xcopy /D /Y /F /C %server%\%file32% \\!machine!\c$\
PsExec.exe -d \\!machine! "C:\%file32%" /q
exit /B
Note: I did not check the purpose nor the logic of your script, I just fixed the for
/goto
issue.