@echo off
call log.bat %~n0
SET CURPATH=%cd%
SET BINPATH=%~dp0
cd /d %USERPROFILE%
SET XMLPATH=%cd%
find "installpath" "RDInstalled.xml" | findstr path > result.txt
type result.txt > result1.txt
set BMCPATH=
for /f tokens^=1^-3^ delims^=^" %%a in (result.txt) do (
	set BMCPATH=%%b
	goto :GETFIN
)
:GETFIN
copy /Y RDInstalled.xml "%CURPATH%\" > result1.txt
cd /d "%BINPATH%"
setlocal ENABLEDELAYEDEXPANSION
for /F %%j in ('dir /B lib') do (
    set CLASSPATH=lib\%%j;!CLASSPATH!
)
set logpath="%CURPATH%"\logs\framework.log
net start GaussDB 1>nul 2>nul

set jrebin=%BMCPATH%\Runtime\jre6.0.18\bin
set querystr=%BMCPATH%\Runtime\jre6\.0\.18\bin
echo "%PATH%" | findstr "%querystr%" 1>nul 2>nul
if %errorlevel% NEQ 0 (
    setx /m path "%PATH%;%jrebin%"
)

"%BMCPATH%/Runtime/jre6.0.18/bin/java" -cp "!CLASSPATH!" com.huawei.lego.gui.main.Main patch 1>>"%logpath%" 2>&1
cd "%CURPATH%"