Batch file assistance

Soldato
Joined
4 Aug 2004
Posts
2,734
Location
on OCUK
Hi all,

Im getting used to the for /f command but I cant seem to get this batch file to work.

What am I doing wrong :o

@Echo off
set JavaTemp=C:\Windows\Gpologs
java -version
if "%ErrorLevel%"=="0" ( goto VersionCheck ) ELSE ( goto Install )

:VersionCheck
java -version 2> %JavaTemp%\java.txt
for /f "tokens=3" %%x in ('find /i "java version" %JavaTemp%\java.txt') do (
if %%~x==1.7.0_45 goto eof
if %%~x==1.7.0_40 goto Install
if %%~x==1.7.0_25 goto Install
if %%~x==1.7.0_21 goto Install
if %%~x==1.7.0_17 goto Install
if %%~x==1.7.0_15 goto Install
)

:Install
msiexec /i "\\servershare\sharename\Java\jre1.7.0_45_x86\jre1.7.0_45.msi" /qn
if %ErrorLevel% EQU 0 (
>>"\\servershare\sharename\jre_1.7.45.x64.csv" echo "%computername%","%date%","%Time%","%ErrorLevel%","Java Runtime 1.7.0_45x86 Installed"
>>"%windir%\GpoLogs\jre_1.7.45.x64.txt" echo "Java Runtime 1.7.0_45x86 Installed"
) else (
>>"\\servershare\sharename\JavaInstallErrors.csv" echo "%computername%","%date%","%Time%","%ErrorLevel%","Error trying to install Java 1.7_45x86"
)


:eof
 
Back
Top Bottom