Search code examples
powershellwindows-shell

Get localized file (resource) names, as shown in Windows Explorer


I am looking for a PowerShell function like Get-LocalizedName($FilePath), returning the localized name of a file or its filename if it is not localized. I know that the localized names are stored in the LocalizedFileNames section of the respective desktop.ini files, but usually as resource file pointers rather than clear names.

Example: For the Administrative Tools folder and the locale de-DE, I want the clear name Windows-Verwaltungsprogramme instead of @%SystemRoot%\system32\shell32.dll,-21762.

I was not able to find such a function, and also was not successful in analyzing the attributes of Get-ChildItem or google a regarding solution.

Is there any such function that I could use from PowerShell (v7)?


Solution

  • I finally found a solution for Get-LocalizedName, digging into 20 years old VBS code using GetDetailsOf:

    function Get-LocalizedName {
        Param([Parameter(Mandatory=$True)][string]$FilePath) 
        $ChildObj = Get-ChildItem $FilePath 
        $FldrName = $ChildObj.DirectoryName 
        $FileName = $ChildObj.Name 
        $Shell    = New-Object -ComObject Shell.Application 
        $Folder   = $Shell.Namespace($FldrName) 
        $File     = $Folder.ParseName($FileName) 
        return $($Folder.GetDetailsOf($File,0))
    }