Windows: Start an Windows APP from command line


Hi,

this post describes how to start a Windows App from command line. Windows Apps cannot be started by calling the exe file in the C:\program files\WindowsApps\xxx folder. This can/must be done my using the explorer.exe.

The Syntax is


C:\> explorer.exe shell:appsFolder\%PackageFamilyNameOfTheApp%!%AppId%


An example the new Windows Terminal (must be installed of course 🙂 ). Look for the package name


PS D:\> Get-AppxPackage | ?{$_.Name -match "Terminal"}
Name : Microsoft.WindowsTerminal
Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture : X64
ResourceId :
Version : 0.11.1121.0
PackageFullName : Microsoft.WindowsTerminal_0.11.1121.0_x64__8wekyb3d8bbwe

Ok, Name is Microsoft.WindowsTerminal. Get the package


PS D:\> $oPackage=Get-AppxPackage Microsoft.WindowsTerminal

Get the manifest to determine the App ID. The AppID is the attribute “Id” of the XML node Package/Applications/Application in AppxManifest.xml.
Read the XML File as an XML object to $oApp


PS D:\> [xml] $AppManifest=Get-Content ([System.IO.Path]::Combine($oPackage.InstallLocation,"AppxManifest.xml"))

Get the PackageFamilyName and the AppID


PS D:\> $PackageFamilyName=$oPackage.PackageFamilyName
PS D:\> $AppId=$AppManifest.Package.Applications.Application.GetAttribute("Id")
PS D:\> Start-Process -FilePath "explorer.exe" ([String]::Format("shell:appsFolder\{0}!{1}",$PackageFamilyName,$AppId))

Or for the Calculator

PS D:\> $oPackage=Get-AppxPackage Microsoft.WindowsCalculator
PS D:\> [xml]$AppManifest=Get-Content ([System.IO.Path]::Combine($oPackage.InstallLocation,"AppxManifest.xml"))
PS D:\> Start-Process -FilePath "explorer.exe" ([String]::Format("shell:appsFolder\{0}!{1}",$oPackage.PackageFamilyName,$AppManifest.Package.Applications.Application.GetAttribute("Id")))

Michael

Leave a Reply Cancel reply