@echo off
@echo Installing Thunderbolt HSA for Windows. Please wait...

cd /d "%~dp0"

cacls.exe "%SystemDrive%\System Volume Information" >nul 2>nul

if %errorlevel%==0 goto Admin

if exist "%temp%\getadmin.vbs" del /f /q "%temp%\getadmin.vbs"

echo Set RequestUAC = CreateObject^("Shell.Application"^)>"%temp%\getadmin.vbs"

echo RequestUAC.ShellExecute "%~s0","","","runas",1 >>"%temp%\getadmin.vbs"

echo WScript.Quit >>"%temp%\getadmin.vbs"
"%temp%\getadmin.vbs" /f

if exist "%temp%\getadmin.vbs" del /f /q "%temp%\getadmin.vbs"

exit

:Admin
:: SET Variables
set CURDIR=%CD%
set APPXNAME=%CURDIR%\333d726a56e3414095dd41bb69a47395.appx
set LICENSE=%CURDIR%\333d726a56e3414095dd41bb69a47395_License1.xml
set DPNDNCY1=%CURDIR%\Microsoft.NET.Native.Framework.2.1_2.1.27427.0_x64__8wekyb3d8bbwe.appx
set DPNDNCY2=%CURDIR%\Microsoft.NET.Native.Runtime.2.1_2.1.26424.0_x64__8wekyb3d8bbwe.appx
set DPNDNCY3=%CURDIR%\Microsoft.VCLibs.140.00_14.0.29231.0_x64__8wekyb3d8bbwe.appx

:: Install HSA
DISM /Online /Add-ProvisionedAppxPackage /PackagePath:"%APPXNAME%" /LicensePath:"%LICENSE%" /DependencyPackagePath:"%DPNDNCY1%" /DependencyPackagePath:"%DPNDNCY2%" /DependencyPackagePath:"%DPNDNCY3%" /Region="All"
IF ERRORLEVEL 1 GOTO ERROR

:EXIT
ECHO Thunderbolt HSA installation finished successfully.
exit /b 0

:ERROR
ECHO Thunderbolt HSA installation failed. Error code: %ERRORLEVEL%
exit /b 1