7

The folders which are open are shown in taskmanager. Perhaps there is a way to access this information with batch or powershell or third party command-line?

explorer-taskmanager.webp

I have also enabled the Restore previous folder windows at logon option... S5032-Folder-Options.webp

So I wonder where the paths of the previously open folder windows is saved.. in regedit? Or in a temporary file somewhere?

goldnick7
  • 440
  • 1
  • 5
  • 14

1 Answers1

13

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.

Keith Miller
  • 10,694
  • 1
  • 20
  • 35