Finding Paths to Special Locations

by May 25, 2016

If you’d like to access any of the following special locations, then we have good news for you:

 
PS C:\> [System.Enum]::GetNames([System.Environment+SpecialFolder])

Desktop
Programs
MyDocuments
Personal
Favorites
Startup
Recent
SendTo
StartMenu
MyMusic
MyVideos
DesktopDirectory
MyComputer
NetworkShortcuts
Fonts
Templates
CommonStartMenu
CommonPrograms
CommonStartup
CommonDesktopDirectory
ApplicationData
PrinterShortcuts
LocalApplicationData
InternetCache
Cookies
History
CommonApplicationData
Windows
System
ProgramFiles
MyPictures
UserProfile
SystemX86
ProgramFilesX86
CommonProgramFiles
CommonProgramFilesX86
CommonTemplates
CommonDocuments
CommonAdminTools
AdminTools
CommonMusic
CommonPictures
CommonVideos
Resources
LocalizedResources
CommonOemLinks
CDBurning 
 

To get the path to any of these locations, use this GetFolderPath method, and submit one of the special locations from the previous list:

 
PS> [System.Environment]::GetFolderPath('Desktop')
C:\Users\tobwe\Desktop

PS> [System.Environment]::GetFolderPath('Cookies')
C:\Users\tobwe\AppData\Local\Microsoft\Windows\INetCookies
 

You can even filter the special locations list if you can’t find what location you are looking for. This line dumps all special locations that contain “do”:

 
PS> [System.Enum]::GetNames([System.Environment+SpecialFolder]) -like '*DO*'

MyDocuments
Windows
CommonDocuments 
 

Twitter This Tip! ReTweet this Tip!