将 AUMID 转换为应用程序名称 C# [英] Convert AUMID to Application Name C#

查看:47
本文介绍了将 AUMID 转换为应用程序名称 C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定 AppUserModelID (AUMID)有没有办法从此数据中获取应用程序名称(而不尝试对 AppUserModelID 进行一些字符串操作)?

Given AppUserModelID (AUMID) Is there a way to get the application name from this data (without attempting to do some string manipulation on the AppUserModelID)?

我正在寻找一个 api 调用来处理这种或那种性质的事情.

I am looking for an api call to handle this or something of that nature.

在下面的情况下,应用程序名称将是Microsoft Edge"

In the case below the application name would be "Microsoft Edge"

 <start:Tile Size="2x2" Column="0" Row="2" AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" />

如何更改以下代码以接受 AUMID 而不是应用程序名称.

How can I alter the following code to accept an AUMID instead of an appname.

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"作为应用程序名称来工作.

this powershell function will work by providing "Microsoft Edge" as the appname.

推荐答案

如果您想通过 AUMID 过滤器在 shell:AppsFolder 中查找 Store/UWP 应用程序通过 Path 属性而不是名称.对于应用商店应用,Path 属性包含应用的 AUMID.

If you want to find a Store/UWP application in the shell:AppsFolder by it's AUMID filter by the Path attribute instead of by the name. For Store apps the Path attribute contains the app's AUMID.

请注意,对于桌面应用程序,Path 属性给出了可执行文件的实际路径.

Note that for desktop apps the Path attribute gives an actual path to the executable.

不要尝试从 AUMID 中查找应用程序名称,只需按其 AUMID 添加即可.

Instead of trying to find the application name from the AUMID simply add them by their AUMID.

天啊:

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?)"
    }
}

这篇关于将 AUMID 转换为应用程序名称 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆