@ECHO off

ECHO.
ECHO ************************************************************************
ECHO Elan Ultranav UI for Windows 10 64bit -WW-
ECHO ************************************************************************
ECHO.

:-------------------------------------
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"
:--------------------------------------

ECHO.
ECHO Start installing Elan Ultranav UI.Please wait...
ECHO.

cd /d "%~dp0"

ECHO Installing APPX:ELANTouchpad
if exist .\ELANTouchpad\24c4e18272f54cb28ab2ff6f301bff2c.appxbundle (
	ECHO Install Store App
	REM powershell -command Add-AppxPackage -Path "%~dp0\ELANTouchpad\9d9a9bf37d1e4a65b3eccfb830431aff.appx"
	DISM.exe /Online /Add-ProvisionedAppxPackage /PackagePath:ELANTouchpad\24c4e18272f54cb28ab2ff6f301bff2c.appxbundle /DependencyPackagePath:ELANTouchpad\Microsoft.VCLibs.140.00_14.0.27323.0_arm__8wekyb3d8bbwe.appx /DependencyPackagePath:ELANTouchpad\Microsoft.VCLibs.140.00_14.0.27323.0_arm64__8wekyb3d8bbwe.appx /DependencyPackagePath:ELANTouchpad\Microsoft.VCLibs.140.00_14.0.27323.0_x64__8wekyb3d8bbwe.appx /DependencyPackagePath:ELANTouchpad\Microsoft.VCLibs.140.00_14.0.27323.0_x86__8wekyb3d8bbwe.appx /LicensePath:ELANTouchpad\24c4e18272f54cb28ab2ff6f301bff2c_License1.xml
) else (
ECHO Install Pre-Store App
	powershell -command Add-AppxPackage -Path .\ELANTouchpad\ELANTouchpad*.appxbundle
)


REG QUERY "HKLM\System\CurrentControlSet\Control\Elantech\UIFunctionOption" /v "TBGSupportTPOnly" | Find "0x0"
IF %ERRORLEVEL% == 1 goto installend

goto COMPLETE

:COMPLETE
ECHO Installation completed.
ECHO.

:installend
ECHO.
ECHO Please restart the system!!
ECHO.


goto END

:END
