gol*_*ck7 7 windows-explorer task-manager batch window files-folders
打开的文件夹显示在任务管理器中。也许有一种方法可以使用批处理、powershell 或第三方命令行来访问这些信息?
所以我想知道以前打开的文件夹窗口的路径保存在 regedit 中的哪里?或者在某个临时文件中?
Kei*_*ler 11
不知道关闭时文件夹保存在哪里,但要获取有关 PowerShell中打开的文件夹的信息,请使用shell.application COM 对象:
@((New-Object -com shell.application).Windows()).Document.Folder | select Title , { $_.Self.Path }
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
要获取虚拟文件夹的人性化名称并查看完整的命名空间路径,您可以定义一个递归函数来提供完整路径(植根于虚拟桌面):
Function NSPath ($oFldr)
{
If ($oFldr.ParentFolder )
{
'{0}\{1}'-f (NSPath $oFldr.ParentFolder), $oFldr.Title
}
Else
{
'\' # or $oFldr.Title
}
}
Run Code Online (Sandbox Code Playgroud)
然后使用该函数,如下所示:
@((New-Object -com shell.application).Windows()).Document.Folder | %{ NSPath $_ }
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
为了便于在批处理中使用,请将该函数添加到您的 PowerShell 配置文件中,如下所示:
@'
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
Run Code Online (Sandbox Code Playgroud)
然后,每当您启动PowerShell时,函数NSPath和 COM 对象$Shell都可以使用。
| 归档时间: |
|
| 查看次数: |
1592 次 |
| 最近记录: |