@echo off
set versionapp=1.00
set errcode=0

REM APP_Title - Avoid using space if possible
set APP_Title=RSTHSABridge

:InstallGUI
Set installgui=false
 
               for /f "tokens=2,3 delims=&" %%P in ('wmic path Win32_PnPEntity where "PNPDeviceID like '%%VEN_8086%%'" get PNPDeviceID') Do (
                                                            if %%P==DEV_282A set installgui=true               
               )
if %installgui% == true goto DISM
               for /f "tokens=2,3 delims=&" %%P in ('wmic path Win32_PnPEntity where "PNPDeviceID like '%%VEN_8086%%'" get PNPDeviceID') Do (
                                                       if %%P==DEV_2822 set installgui=true
		)
	       for /f "tokens=2,3 delims=&" %%P in ('wmic path Win32_PnPEntity where "PNPDeviceID like '%%VEN_8086%%'" get PNPDeviceID') Do (
                                                           if %%P==DEV_02D7 set installgui=true
		)
 	       for /f "tokens=2,3 delims=&" %%P in ('wmic path Win32_PnPEntity where "PNPDeviceID like '%%VEN_8086%%'" get PNPDeviceID') Do (
                                                            if %%P==DEV_06D6 set installgui=true
                )
 	       for /f "tokens=2,3 delims=&" %%P in ('wmic path Win32_PnPEntity where "PNPDeviceID like '%%VEN_8086%%'" get PNPDeviceID') Do (
                                                          if %%P==DEV_43D6 set installgui=true
                )
 	      
if %installgui% == false goto End

:DISM
REM Need Update: DISM /ONLINE <DISM_COMMAND>
REM Path within the DISM_Command should be based within \SRC\APP\ directory
Set DISM_Command=/Add-ProvisionedAppxPackage /PackagePath:".\0466b44f0d2c480ea308474bb59011f5.appxbundle" /LicensePath:".\0466b44f0d2c480ea308474bb59011f5_License1.xml" /DependencyPackagePath:".\Microsoft.VCLibs.140.00.UWPDesktop_14.0.30035.0_x64__8wekyb3d8bbwe.appx" /Region="all" 

rem
rem Loggings of the UWP installation are captured in these logs for debugging purpose
rem
set Log_Folder=c:\programdata\hp\logs\UWP
if not exist "%Log_Folder%" md "%Log_Folder%"

set APP_Log=%Log_Folder%\%APP_Title%.log
set APPDISM_Log=%Log_Folder%\%APP_Title%_DISM.log
set DISMCMD=DISM /scratchdir:"%Log_Folder%" /LogPath:"%APPDISM_Log%"

rem
rem The parameter passed from the caller, if any, is assumed to be the target offline image:
rem     <path_to_offline_image>
rem
rem to specify an offline Windows image to which the installation is targeted.
rem
set Param1=%1

echo. >> "%APP_Log%"
echo ^>^> %~f0 >> "%APP_Log%"
echo ^>^> %date% %time% >> "%APP_Log%"
echo. >> "%APP_Log%"

echo Installing "%APP_Title%"... >> "%APP_Log%"
echo. >> "%APP_Log%"

echo *pushd "%~dp0app" >> "%APP_Log%"
pushd "%~dp0app" >> "%APP_Log%" 2>&1

if defined Param1 goto lbl_Offline


:lbl_Online

set TargetImage=/online
goto lbl_CommonOps


:lbl_Offline

set TargetImage=/image:%Param1%
goto lbl_CommonOps


:lbl_CommonOps

rem
rem App installation 
rem
echo *%DISMCMD% %TargetImage% %DISM_Command% >> "%APP_Log%"
%DISMCMD% %TargetImage% %DISM_Command% >> "%APP_Log%" 2>&1
set errcode=%errorlevel%


:end_InstallApp

echo *popd >> "%APP_Log%"
popd >> "%APP_Log%" 2>&1

echo. >> "%APP_Log%"
echo Done installing "%APP_Title%"! >> "%APP_Log%"

echo. >> "%APP_Log%"
echo *exit /b %errcode% >> "%APP_Log%"
echo. >> "%APP_Log%"
echo ^<^< %~f0 >> "%APP_Log%"
echo ^<^< %date% %time% >> "%APP_Log%"
echo. >> "%APP_Log%"

exit /b %errcode%
:End
