在互联网的其他地方,有建议称启动“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 启动 Store 应用(桌面或 UWP)并传递参数?
答案1
尝试:
Start-Process -FilePath "explorer.exe" "shell:appsFolder\19568ShareX.ShareX_egrzcvs15399j!App"