I think I started using Shell commands when I went looking for the startup folder in Windows 8. A post from Jasone’s MSDN blog suggested the easiest way to open it was by typing “Shell:Startup” in from the run box (WIN+R). I became curious about how to enumerate a list of these shortcuts, and how they could be opened with PowerShell. I did some research and found the information about these is found in HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\FolderDescriptions. Get-ShellFolders.ps1 is an example of how to read that information, and use it to launch a shell command within PowerShell.
#Alan Kaplan 3-15-2018 #List and open Shell Folders from within PowerShell $regPath = 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\FolderDescriptions' $shellItem = Get-ChildItem $regPath | ForEach-Object { $sf = Get-ItemPropertyvalue -Path $_.psPath -Name Name Try { #get real path? $rPath = Get-ItemPropertyvalue -Path $_.psPath -Name RelativePath } Catch {$rPath = 'none'} Try { $ePath = [environment]::getfolderpath($sf) } Catch {$ePath = 'none'} [PSCustomobject]@{ 'Shell Folder' = $sf 'Command' = "Shell`:$sf" 'Environment' = $ePath 'Relative Path' = $rPath } } | Sort-Object -Property 'Shell Folder'| Out-GridView -OutputMode Single -Title "Select Shell Folder to Open" #The pipeline broke here, so I assigned output to $ShellItem, above Try { #Invoke-Execute does not work, but start-process does Start-Process -FilePath $shellItem.Command } Catch { #Some disabled features may error with file not found Write-Warning $Error[0].Exception.Message }
Run the script, select a shell folder, and click OK to open.