如何从命令行启动 Windows 10 应用程序?

Rya*_*ach 5 powershell cmd.exe windows-10

在互联网的其他地方,有人建议启动“Windows 10 应用程序”(又名 UWP 应用程序)的“最佳”方式是通过新的 explorer.exe 进程,使用“shell:”协议(如果尚未注册,则为自己的协议)

param([string]$AppName)

$Path="shell:appsfolder\"+(Get-AppXPackage | where{$_.Name -match "$AppName"} | select -expandproperty packagefamilyname)+"!App"

return $Path
Run Code Online (Sandbox Code Playgroud)

但是,调用此脚本会导致

PS C:\Users\RyanLeach\Documents\WindowsPowerShell\Scripts> $ShareX = ./findapp.ps1 ShareX

PS C:\Users\RyanLeach\Documents\WindowsPowerShell\Scripts> $ShareX
shell:appsfolder\19568ShareX.ShareX_egrzcvs15399j!App

PS C:\Users\RyanLeach\Documents\WindowsPowerShell\Scripts> Start-Process -FilePath $ShareX
Start-Process : This command cannot be run due to the error: The system cannot find the file specified.
At line:1 char:1
+ Start-Process -FilePath $ShareX
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
Run Code Online (Sandbox Code Playgroud)

那么如何通过命令行/PowerShell 传递参数来启动应用商店应用程序(桌面或 UWP)?

bat*_*a09 4

尝试:

Start-Process -FilePath "explorer.exe"  "shell:appsFolder\19568ShareX.ShareX_egrzcvs15399j!App"
Run Code Online (Sandbox Code Playgroud)