尽管您的后者 ( TenForums ) 链接看似指向创建快捷方式,但您可以使用批处理文件中的最终命令行作为快捷方式目标。
我编写了以下 PowerShell 脚本57498059.ps1
来自动化他们的(有点复杂的)指南:
Import-Module -Name 'Appx'
$StickyNotesName = 'Microsoft.MicrosoftStickyNotes'
$StickyNotesPack = Get-AppxPackage -Name $StickyNotesName
$StickyNotesManifest = Join-Path -Path $StickyNotesPack.InstallLocation `
-ChildPath 'AppxManifest.xml'
$StickyNotesXml = New-Object Xml
$StickyNotesXml.Load("$StickyNotesManifest")
$StickyNotesExec = 'explorer.exe shell:appsFolder\' +
$StickyNotesPack.PackageFamilyName + '!' +
$StickyNotesXml.Package.Applications.Application.Id
"@$StickyNotesExec" | Out-File -Encoding ascii -FilePath ".\stikynot.bat"
# write `stikynot.bat` to a folder listed in Windows %path% variable
# you can type `stikynot` in the run prompt or `cmd` prompt then
"$StickyNotesExec" # return value: cmd command to launch Sticky Notes
Write-Host "$StickyNotesName - done" -ForegroundColor Cyan
<# check if it works #>
Invoke-Expression "$StickyNotesExec"
<##>
结果(Sticky Notes
应用程序在我的Windows 10 上运行):
PS D:\PShell> .\SO\57498059.ps1
explorer.exe shell:appsFolder\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe!App
Microsoft.MicrosoftStickyNotes - done
type .\stikynot.bat
@explorer.exe shell:appsFolder\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe!App