:: REM CMD File Location = C:\SWWORK\A2AppM\%MODNAME%.CMD



:: MODNAME variable is ALREADY set by module process!
SET APPXSHORTNAME=RealtekSemiconductorCorp.RealtekAudioControl
SET APPXFULLNAME=RealtekSemiconductorCorp.RealtekAudioControl_1.5.191.0_neutral_~_dt26b99r8h8gj


ECHO START Module AppX Install - AppName: %APPXSHORTNAME% - ModuleName: %MODNAME% >>C:\SWWORK\Modules.log


:: Add dependencies
DISM /Online /Add-ProvisionedAppxPackage /PackagePath:C:\SWWORK\%MODNAME%\216d11a8c76c486abc249503989cef4b.appxbundle /LicensePath:C:\SWWORK\%MODNAME%\216d11a8c76c486abc249503989cef4b_License1.xml /region="all"

:: REM Retrieve full PFN for the installed app (Which contains version and architecture)
ECHO Retrieving PFN for %APPXSHORTNAME% >>c:\SWWORK\modules.log
DISM /online /Get-ProvisionedAppxPackages /english > %TEMP%\appx-haystack.txt
find /i "%APPXSHORTNAME%" %TEMP%\appx-haystack.txt > %TEMP%\appx-needle.txt
if errorlevel 1 (
                ECHO No matching appx for %APPXSHORTNAME% Found >>C:\SWWORK\modules.log
                exit /b 0
			)

FOR /F "tokens=1* delims==: " %%A IN ('TYPE "%TEMP%\appx-needle.txt"') DO IF /i %%A==PACKAGENAME SET APPXPACKAGEFULLNAME=%%B
ECHO APPX FULL NAME FOR "%APPXSHORTNAME%" IS "%APPXPACKAGEFULLNAME%"  >>C:\SWWORK\modules.log
del %TEMP%\appx-haystack.txt
del %TEMP%\appx-needle.txt

ECHO END Module AppX Install - AppName: %APPXSHORTNAME% - ModuleName: %MODNAME% >>C:\SWWORK\Modules.log

:END 
::SET MODNAME=
SET APPXFULLNAME=
SET APPXSHORTNAME=
SET APPXPACKAGEFULLNAME=
exit /b 0
