@exit /b

:embed:
[Environment]::CurrentDirectory = (Get-Location -PSProvider FileSystem).ProviderPath
Add-Type -Path .\Microsoft.Dism.dll
[Microsoft.Dism.DismApi]::InitializeEx(2, $g, $c)
$s = [Microsoft.Dism.DismApi]::OpenOfflineSession($m)
$l = (Get-Content .\AppsToAdd.txt)
ForEach ($a in $l)
{
  $d = [IO.Path]::GetDirectoryName($a)
  If ($d -Eq 'MSIXFramework')
  {
    echo ([IO.Path]::GetFileNameWithoutExtension($a))
    try {[Microsoft.Dism.DismApi]::AddProvisionedAppxPackage($s, $a, $null, $null, $null)} catch {}
    continue
  }
  echo ($d)
  If (Test-Path ($d + '\AppxMetadata\Stub\*'))
  {
    $t = 2
  }
  Else
  {
    $t = 0
  }
  try {[Microsoft.Dism.DismApi]::AddProvisionedAppxPackage($s, $a, $null, $null, $d + '\License.xml', $null, 'all', $t)} catch {}
}
[Microsoft.Dism.DismApi]::CloseSession($s)
[Microsoft.Dism.DismApi]::Shutdown()
:embed:
