Convert AUMID to Application Name C#

后端 未结 1 990
盖世英雄少女心
盖世英雄少女心 2021-01-29 09:23

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

I am

相关标签:
1条回答
  • 2021-01-29 10:07

    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.

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

    Instead of trying to find the application name from the AUMID simply add them by their 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?)"
        }
    }
    
    0 讨论(0)
提交回复
热议问题