@echo off

net session >nul 2>&1
if %errorlevel% equ 0 (
    echo Installing...
    goto Install 
) else (
    echo FAILED: Please run this script as admin. Exiting.
    goto End
)

:Install

pushd %~dp0

pushd bin
EnableVROverlay_x64.exe -uninstall
popd

REM echo "Installing Oculus VR events manifest"
reg query "HKLM\SOFTWARE\Wow6432Node\Oculus VR, LLC\Oculus" >nul 2>nul
if %errorlevel% equ 0 goto Oculus_Install
echo WARNING: FCAT VR Capture should be installed after Oculus runtime installation if Oculus support is desired

:Oculus_Install
pushd etw_oculus 
call install.cmd >nul 2>nul
popd

REM echo "Installing FCAT events for OpenVR and Oculus manifest"
pushd etw_fcat
call htcvive_install.bat >nul 2>nul
popd

:InstallComplete

echo SUCCESS: Installation completed

:End
pause