给定 AppUserModelID (AUMID)
有没有办法从这些数据中获取应用程序名称(而不尝试对 AppUserModelID 进行一些字符串操作)?
我正在寻找一个 api 调用来处理这个或类似的事情。
在下面的情况下,应用程序名称将为“Microsoft Edge”
<start:Tile Size="2x2" Column="0" Row="2" AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" />
如何更改以下代码以接受 AUMID 而不是应用程序名称。
function Pin-App { param(
[string]$appname,
[switch]$unpin
)
try{
if ($unpin.IsPresent){
((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from Start'} | %{$_.DoIt()}
return "App '$appname' unpinned from Start"
}else{
((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Pin to Start'} | %{$_.DoIt()}
return "App '$appname' pinned to Start"
}
}catch{
Write-Error "Error Pinning/Unpinning App! (App-Name correct?)"
}
}
此 powershell 功能将通过提供“Microsoft Edge”作为应用程序名称来工作。
If您想在以下位置找到 Store/UWP 应用程序shell:AppsFolder
通过它的 AUMID 过滤器Path
属性而不是名称。对于商店应用程序Path
属性包含应用程序的 AUMID。
请注意,对于桌面应用程序Path
属性给出了可执行文件的实际路径。
无需尝试从 AUMID 查找应用程序名称,只需按 AUMID 添加它们即可。
Jeez:
function Pin-App { 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 Start'} | %{$_.DoIt()}
return "App '$aumid' unpinned from Start"
}else{
((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Path -eq $aumid}).Verbs() | ?{$_.Name.replace('&','') -match 'Pin to Start'} | %{$_.DoIt()}
return "App '$aumid' pinned to Start"
}
}catch{
Write-Error "Error Pinning/Unpinning App! (App-Name correct?)"
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)