@echo off
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"

@echo OFF

if not exist .\log\ (
	mkdir .\log\
)

echo %date% %time% >>.\log\intall.log 2>&1
echo backup begin...
call .\shell\backup.bat >>.\log\intall.log 2>&1
if %errorlevel% == 0 (
	echo backup successfully.
) else (
	echo backup failed.
	pause;
	exit
)

set ori=%cd%
cd..
set bbd=%cd%
cd %ori%
set LOGCENTER_ROOT=%bbd%

echo %date% %time% >>.\log\intall.log 2>&1
echo update mysql begin...
call .\shell\update_mysql.bat >>.\log\intall.log 2>&1
if %errorlevel% == 0 (
	echo update mysql successfully.
) else (
	echo update mysql failed.
	pause;
	exit
)

echo %date% %time% >>.\log\intall.log 2>&1
echo update ATIC begin...
call .\shell\update_atic.bat >>.\log\intall.log 2>&1
if %errorlevel% == 0 (
	echo update ATIC successfully.
) else (
	echo update ATIC failed.
	pause;
	exit
)

echo %date% %time% >>log\intall.log 2>&1
echo Update finished.
pause;
