:: 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.1.133.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%\3834d727703d4664ac159851f1d234b7.appxbundle /LicensePath:C:\SWWORK\%MODNAME%\3834d727703d4664ac159851f1d234b7_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
