last variable in for loop repeats

October 8, 2010 at 12:55:56
Specs: Windows 7
I've almost got this batch working, but the last variable always repeats itself. What am I missing or what did I do wrong?

For instance, the output would be:
server1 x86 check
server1 x86 good
server2 x86 check
server2 x86 good
server3 x64 check
server3 x64 good
server3 x64 check
server3 x64 good

@echo off
setlocal
set arch=x86
set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
for /f "tokens=*" %%a IN (servers.txt) do call :_TRIM %%a && call :_INS %%a

:_INS
reg.exe query \\%pc%\%RegQry% | findstr /i %arch% > nul
if %ERRORLEVEL% equ 0 (
echo %pc% x86 check
call :_x86
) else (
echo %pc% x64 check
call :_x64
)
goto :_END

:_x86
set ver=8.3.2.1593
filever.exe "\\%pc%\c$\program files\vmware\vmware tools\vmtools.dll" | findstr /i %ver% > nul
if %ERRORLEVEL% equ 0 (
echo %pc% x86 good
) else (
echo %pc% x86 install
)
goto :_END

:_x64
set ver=8.3.2.1593
filever.exe "\\%pc%\c$\program files\vmware\vmware tools\vmtools.dll" | findstr /i %ver% > nul
if %ERRORLEVEL% equ 0 (
echo %pc% x64 good
) else (
echo %pc% x64 install
)
goto :_END

:_TRIM
rem trim the whitespace at the end of the servername
set pc=%*
goto :_END

:_END
rem eof



See More: last variable in for loop repeats

Report •

#1
October 8, 2010 at 13:30:44
After the FOR you missed GOTO :_END

By the way you may directly code GOTO :EOF without declaring the label :_END (and :EOF) since EOF is the built-in return point for the main body and its subroutines (as RETURN or GOBACK in programming languages).


Report •

#2
October 8, 2010 at 20:38:14
That worked! Thanks!

Thanks for the protip too.


Report •
Related Solutions


Ask Question