【发布时间】:2017-08-23 17:54:04
【问题描述】:
在给定 AUMID 的情况下,以下代码将固定 Metro 应用以启动
如果你改变了
-match 'Pin To Start'
很遗憾,将匹配更改为“固定到任务栏”不起作用。这是怎么回事?
function Pin-Taskbar { param(
[string]$aumid,
[switch]$unpin
)
try{
if ($unpin.IsPresent){
((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Path -eq $aumid}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from Taskbar'} | %{$_.DoIt()}
return "App '$aumid' unpinned from Taskbar"
}else{
((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Path -eq $aumid}).Verbs() | ?{$_.Name.replace('&','') -match 'Pin to Taskbar'} | %{$_.DoIt()}
return "App '$aumid' pinned to Taskbar"
}
}catch{
Write-Error "Error Pinning/Unpinning App! (App-Name correct?)"
}
}
Pin-Taskbar king.com.CandyCrushSaga_kgqvnymyfvs32!App
【问题讨论】:
-
您不应该能够以编程方式告诉用户您的应用对他们很重要。 "Why is there no programmatic access to the Start menu pin list?" - The Old New Thing
-
@TessellatingHeckler 一定有办法
-
"注意应用程序不能以编程方式将自己固定到任务栏。该功能只为用户保留。" msdn.microsoft.com/en-us/library/…
标签: c# windows powershell