Use this when writing or interpreting Windows paths correctly.
Paths
Windows paths can be absolute (C:\Users\pat\file.txt), relative (.\data), UNC (\\server\share\file) or device paths (\\?\C:\). They are case-insensitive and use backslashes, though forward slashes often work.
1. Absolute (C:\x) vs relative (.\x) path?
2. Working directory: Get-Location.
3. Quote paths with spaces.
4. PowerShell providers: HKLM:, Cert: paths.
5. Resolve: Resolve-Path.
path string → resolved against drive/current directory → object
Context & applicabilityCommon mistakes · platform/version boundaries
- Paths with spaces not quoted in scripts and scheduled tasks.
- Relative paths in scheduled tasks (working directory is
C:\Windows\System32). - Hard-coded
C:\Users\nameinstead of%USERPROFILE%/$env:USERPROFILE. - Mixing
/and\in tools that only accept one.
Operational reference
Fast context before you go deeper.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Windows paths are case-insensitive.
- Relative paths resolve against the current working directory.
- Paths with spaces must be quoted.
Get-ChildItem <path> -Force— contents including hiddenTest-Path <path>— exists?Resolve-Path <path>— full pathGet-Item <path> | fl *— attributes and timestamps
ReferenceWhy it matters1 section · depth on demand
Path types
| Type | Example |
|---|---|
| Absolute (drive) | C:\Users\pat\file.txt |
| Relative | .\data\file.txt, ..\logs |
| UNC | \\server\share\folder\file.txt |
| Extended-length | \\?\C:\very\long\path |
| Device | \\.\PhysicalDrive0 |
Paths are case-insensitive. Reserved names (CON, NUL, COM1, LPT1) cannot be used as file names, and names cannot end with a space or period. In PowerShell, use Join-Path and Resolve-Path instead of string concatenation; quote paths with spaces.
ReferenceImportant terms & boundaries2 sections · depth on demand
Environment variables
| Variable | Typical value |
|---|---|
%USERPROFILE% | C:\Users\name |
%APPDATA% | C:\Users\name\AppData\Roaming |
%LOCALAPPDATA% | C:\Users\name\AppData\Local |
%PROGRAMDATA% | C:\ProgramData |
%SystemRoot% | C:\Windows |
%TEMP% | C:\Users\name\AppData\Local\Temp |
In depth
Windows path forms:
| Form | Example | Notes |
|---|---|---|
| Absolute | C:\Data\file.txt | Drive + path |
| Relative | ..\logs\app.log | From current directory |
| UNC | \\server\share\dir | Network |
| Extended-length | \\?\C:\very\long\path | Bypasses MAX_PATH, no normalisation |
| Device | \\.\PhysicalDrive0, \\.\COM1 | Devices |
| Volume GUID | \\?\Volume{GUID}\ | Volumes without letters |
Reserved names cannot be used as file names: CON, PRN, AUX, NUL, COM1–9, LPT1–9; trailing spaces and dots are stripped by normal APIs.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Files & Directories → Paths. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/windows-server/storage/file-server/ntfs-overview · confidence 94%