Saturday, March 22, 2014

How to acquire a list of special folders

If you were wondering how to acquire a list of special folders, this is an easy way of doing it:

$ws = new-object -comobject wscript.shell
$rt = $ws.SpecialFolders

When you type $rt on the next line:

$rt
And press enter, Powershell will display a list of special folders like this:

C:\Users\Public\Desktop
C:\ProgramData\Microsoft\Windows\Start Menu
C:\ProgramData\Microsoft\Windows\Start Menu\Programs
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
C:\Users\Administrator\Desktop
C:\Users\Administrator\AppData\Roaming
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Printer Shortcuts
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Templates
C:\Windows\Fonts
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Network Shortcuts
C:\Users\Administrator\Desktop
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\SendTo
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Recent
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Star
C:\Users\Administrator\Favorites
C:\Users\Administrator\Documents
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs

Suppose you knew that the special folder for fonts would always be the 9th one -- it is zero based:








$rt.Item(8)
C:\Windows\Fonts

No comments:

Post a Comment