如何從命令列啟動 Windows 10 應用程式?

如何從命令列啟動 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

但是,呼叫此腳本會導致

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

那麼如何透過命令列/PowerShell 傳遞參數來啟動應用程式商店應用程式(桌面或 UWP)?

答案1

嘗試:

Start-Process -FilePath "explorer.exe"  "shell:appsFolder\19568ShareX.ShareX_egrzcvs15399j!App"

相關內容