A PowerShell script to analyze how Windows Shell interprets various paths (local directories, \\wsl$
, shell:
URIs, etc.) by retrieving Shell attributes (SFGAO_*
) via the Win32 API. It helps explain why some locations appear in folder picker dialogs (FOS_PICKFOLDERS
) but not in regular file open/save dialogs.
In Windows, the Shell can treat different paths in different ways—some are recognized as “real” file system objects, others as “virtual” or “namespace” extensions. This check.ps1 script uses low-level Shell APIs (in particular, SHParseDisplayName
) to parse a user-supplied path and report back critical SFGAO flags.
These flags determine whether a path is considered:
- A true filesystem object (
SFGAO_FILESYSTEM
), - A file system ancestor (
SFGAO_FILESYSANCESTOR
), - A folder-like container (
SFGAO_FOLDER
), - Or something else entirely.
Key Insight:
- A location without
SFGAO_FILESYSTEM
but withSFGAO_FILESYSANCESTOR
often does appear in a folder picker dialog but is hidden from classic file open/save dialogs, since the latter may require a full Win32 filesystem path.
- Retrieves Shell attributes (
SFGAO_*
) for a specified path usingSHParseDisplayName
. - Highlights the difference between true filesystem objects (
SFGAO_FILESYSTEM
) and “virtual” or “namespace-only” folders (SFGAO_FILESYSANCESTOR
). - Explains why certain paths (e.g.,
\\wsl$
, libraries likeshell:PicturesLibrary
, or network shares) behave differently in Windows UI. - Interactive: prompts for a path, then shows the parsed attributes.
- User inputs a path in PowerShell (e.g.,
\\wsl$\Ubuntu
,C:\Windows
,shell:PicturesLibrary
, etc.). - The script calls
SHParseDisplayName
to parse the path into a PIDL (Pointer to an Item ID List). - Windows Shell returns flags (
SFGAO_*
) describing the item (is it a real FS object? is it an ancestor? a folder?). - The script displays these flags, clarifying how the Shell classifies that location.
SFGAO_FILESYSTEM
indicates the path is part of the real file system in the Shell’s view.SFGAO_FILESYSANCESTOR
means the path can lead to real file-system objects but isn’t itself a classic Win32 filesystem path.FOS_PICKFOLDERS
(the folder picker dialog flag) often shows items withSFGAO_FILESYSANCESTOR
, even withoutSFGAO_FILESYSTEM
.- This is why WSL (
\\wsl$
) orshell:PicturesLibrary
might appear in folder dialogs but remain hidden in a standard file open/save dialog.
- This is why WSL (
- Windows 10/11 with standard Shell components
(On Windows Server Core or minimal installations, the necessary Shell functionality may be absent or limited.) - PowerShell 5.1+ or later.
- Sufficient permissions to run scripts (
Set-ExecutionPolicy
) or a signed script.
- Clone or download this repository.
- Open a PowerShell session.
- Navigate to the folder containing
check.ps1
. - Run the script:
.\check.ps1