Don't know where folders are saved at shutdownn, but to get info on open folders in PowerShell,use the shell.application COM object:
@((New-Object -com shell.application).Windows()).Document.Folder | select Title , { $_.Self.Path }
Sample Output
PS C:\...\keith>@((New-Object -com shell.application).Windows()).Document.Folder | select Title , { $_.Self.Path }
Title $_.Self.Path
----- --------------
This PC ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
Quick access ::{679F85CB-0220-4080-B29B-5540CC05AAB6}
Windows (C:) C:\
SendTo C:\Users\keith\AppData\Roaming\Microsoft\Windows\SendTo
To get humann-friendly names for virtual folders as well as see the full namespace path, you can define a recursive function that gives you the full path (rooted in the virtual Desktop):
Function NSPath ($oFldr)
{
If ($oFldr.ParentFolder )
{
'{0}\{1}'-f (NSPath $oFldr.ParentFolder), $oFldr.Title
}
Else
{
'\' # or $oFldr.Title
}
}
Then use the function like so:
@((New-Object -com shell.application).Windows()).Document.Folder | %{ NSPath $_ }
OUtput:
PS C:\...\keith>@($shell.Windows()).Document.Folder | %{ NSPath $_ }
\\This PC
\\Quick access
\\Keith Miller\Documents
\\This PC\Documents
\\This PC\Windows (C:)\Users\keith\Documents
To make it easy to use from within batch, add the function to your PowerShell profile like so:
@'
New-Object -com shell.application
Function NSPath ($oFldr)
{
If ($oFldr.ParentFolder )
{
'{0}\{1}'-f (NSPath $oFldr.ParentFolder), $oFldr.Title
}
Else
{
'\' # or $oFldr.Title
}
}
'@ | add-content $PROFILE
and then both the function NSPath
and the COM object $Shell
are available for use whenever you launch PowerShell.