Launching Modern Applications from the Command Line
Friday, 30 October 2015
We had an interesting discussion at work the other day about how to launch modern Windows applications from the command line.
There are a few solutions out there (Tome’s is close), although few of them are happy with their results 🙂
Many of them rely on protocol handlers (i.e.: “start bingnews://”), but that means memorizing a bunch of protocol handler prefixes.
Tome’s blog mentions the Get-AppxPackage cmdlet – the real workhorse of a proper solution.
Modern applications are placed in Appx packages. These packages may contain one or more applications. If an AppxPackage contains several applications, these will be listed in its package manifest – which you can retrieve through Get-AppxPackageManifest. The manifest is XML, which PowerShell’s XML support makes crazy easy to navigate.
Here’s an example of getting all of the modern applications that you can launch – place it in Get-AppxPackageEx.ps1:
There’s an example of getting all the apps you might want to launch. When it comes to launching one, the secret is to use the Shell handler to do it. Here’s a script that accomplishes it:
204 [C:\temp] >> Start-AppxPackage *twitter* -whatif What if: Performing the operation "Start-AppxPackage.ps1" on target "shell:AppsFolder\9E2F88E3.Twitter_wgeqdkkx372wm!App".