Skip to content

Instantly share code, notes, and snippets.

@apples
Last active March 31, 2021 20:40
Show Gist options
  • Save apples/120b73cbc257b7aeef9e14c9a7f4d018 to your computer and use it in GitHub Desktop.
Save apples/120b73cbc257b7aeef9e14c9a7f4d018 to your computer and use it in GitHub Desktop.
PowerShell 4 Dummies - Chapter 69: Obtaining info about an app package

Firstly, a "package" is a collection of files, and may contain multiple "applications", which are the executables.

You can list the details about the package with Get-AppxPackage, as discussed.

PS C:\Users\dbral> $pkg = get-appxpackage -name *terminal*
PS C:\Users\dbral> $pkg


Name              : Microsoft.WindowsTerminal
Publisher         : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture      : X64
ResourceId        :
Version           : 1.6.10571.0
PackageFullName   : Microsoft.WindowsTerminal_1.6.10571.0_x64__8wekyb3d8bbwe
InstallLocation   : C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.6.10571.0_x64__8wekyb3d8bbwe
IsFramework       : False
PackageFamilyName : Microsoft.WindowsTerminal_8wekyb3d8bbwe
PublisherId       : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle          : False
IsDevelopmentMode : False
NonRemovable      : False
IsPartiallyStaged : False
SignatureKind     : Store
Status            : Ok

PowerShell time: If you want to access one of those returned fields, you can just say $pkg.InstallLocation, or wrap the command in parens like I did earlier.

Now, each "package" has a "manifest" which details everything else we could want to know about the package.

We can get the manifest with get-appxpackagemanifest:

PS C:\Users\dbral> $mf = get-appxpackagemanifest $pkg
PS C:\Users\dbral> $mf

xml                            Package
---                            -------
version="1.0" encoding="utf-8" Package

PowerShell time: This time, the Package field isn't just a string, it's a nested struct kinda thing which represents the whole manifest.

The part we care about though, is the applications. In this case, we only have one application, so we can access it directly (without a loop):

PS C:\Users\dbral> $mf.package.applications.application


Id             : App
Executable     : WindowsTerminal.exe
EntryPoint     : Windows.FullTrustApplication
VisualElements : VisualElements
Extensions     : Extensions

So there you go, that's your app exe.

However, none of this really matters, because you cannot simply run that .exe

Packages require special permissions and security checks to be run, which won't happen if you just run the .exe directly.

However, in the previous command examples, we do actually have enough info to launch the app.

From the package info, we get the PackageFamilyName:

PS C:\Users\dbral> $pkgname = $pkg.PackageFamilyName
PS C:\Users\dbral> $pkgname
Microsoft.WindowsTerminal_8wekyb3d8bbwe

And from the application manifest, we need the application's ID:

PS C:\Users\dbral> $appid = $mf.package.applications.application.id
PS C:\Users\dbral> $appid
App

And together, we can use these to launch the app, by asking the shell to do it for us:

start shell:AppsFolder\$pkgname!$appid

Or, expanded:

shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment