@ECHO OFF
::MODE CON: COLS=65 LINES=35
color 5e
@echo off
:: BatchGotAdmin (Run as Admin code starts)
REM  --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    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"
:: BatchGotAdmin (Run as Admin code ends)
ECHO]
ECHO Upgrade Started at %time% on %date% on workstation %computername% on %userprofile%\Desktop

ECHO ..................................................
ECHO Keep DB backups in external drives regularly to avoid any data loss
ECHO Keep CAS server connectd to VPN network to Sync data regularly 
ECHO Updating CAS Server Version 4.5 Version 1.8, Please Wait ..... 
ECHO ..................................................
ECHO]
COLOR 5E
TIMEOUT /T 5 /NOBREAK
: Name of the database user with rights to all tables
set dbuser=root

:: Password for the database user
set dbpass=root

:: Error log path
set mysqlexe="C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin\mysql.exe"


set filepath=.\Application\NewLawsScriptCombined.sql


IF EXIST C:\CCTNSApplication (GOTO NOWINDIR) ELSE (GOTO END)


:NOWINDIR


xcopy ".\Application\lib\*.*" "C:\CCTNSApplication\CCTNSApplication\lib" /q /s /i



%mysqlexe% --user=%dbuser% --password=%dbpass% -f  <  %filepath%


ECHO :::::::::::::::::"Script Executed Successfully":::::::::::::::::::::
ECHO]



ECHO]
Echo ::::::::::Please check Version details in CAS login Page after Updating Patch::::::::
ECHO]
pause

:END
ECHO ::::::Server Patch updated successfully:::::

