我正在尝试找到一种方法来获取我实际桌面背景的“真实路径”。我使用幻灯片放映,文件夹中有很多文件(4k+),其中一些我想快速删除。
到目前为止我尝试过的:
%AppData%\Microsoft\Windows\Themes\CachedFiles
- 仅包含实际图像
%AppData%\Microsoft\Windows\Themes\TranscodedWallpaper
- 文件路径和文件名转码
HKEY_CURRENT_USER\Control Panel\Desktop\WallPaper
- 指向上面的文件
HKEY_CURRENT_USER\Control Panel\Desktop\TranscodedImageCache
- 同上
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers
- 仅显示文件的副本
经过一番研究后我的解决方案是:
使用来自的转码路径
HKEY_CURRENT_USER\Control Panel\Desktop\TranscodedImageCache
我创建了一个命令
$TIC=(Get-ItemProperty 'HKCU:\Control Panel\Desktop' TranscodedImageCache -ErrorAction Stop).TranscodedImageCache
[System.Text.Encoding]::Unicode.GetString($TIC) -replace '(.+)([A-Z]:[0-9a-zA-Z\\])+','$2'
这个在 *.ps1 文件或 powershell 终端中工作:
Start-Process -FilePath "$env:SystemRoot\explorer.exe" -ArgumentList "/select,`"$([System.Text.Encoding]::Unicode.GetString((Get-ItemProperty 'HKCU:\Control Panel\Desktop' TranscodedImageCache -ErrorAction Stop).TranscodedImageCache) -replace '(.+)([A-Z]:[0-9a-zA-Z\\])+','$2')`""
并尝试将其添加到 Windows 背景的右键菜单中
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\DesktopBackground\Shell\WPTargetDir]
@="Open Desktop Background File Location"
icon="imageres.dll,108"
position="bottom"
[HKEY_CLASSES_ROOT\DesktopBackground\Shell\WPTargetDir\command]
@="PowerShell -Command "Start-Process -FilePath `"$env:SystemRoot\explorer.exe`" -ArgumentList `"/select,`"$([System.Text.Encoding]::Unicode.GetString((Get-ItemProperty 'HKCU:\Control Panel\Desktop' TranscodedImageCache -ErrorAction Stop).TranscodedImageCache) -replace '(.+)([A-Z]:[0-9a-zA-Z\\])+','$2')`"`";Read-Host""
*Read-Host
仅用于捕捉错误信息
我收到一个错误,有人可以解释原因或提供解决方案吗?
錯誤是"No position parameter was found that accepts the argument "<path_to_file>"
。
+ Start-Process -FilePath `$env:SystemRoot\explorer.exe` -ArgumentList ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand
谢谢
答案1
解决方案:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\DesktopBackground\Shell\WPTargetDir]
"icon"="imageres.dll,108"
@="Open Desktop Background File Location"
[HKEY_CLASSES_ROOT\DesktopBackground\Shell\WPTargetDir\command]
@=hex(2):25,00,63,00,6f,00,6d,00,73,00,70,00,65,00,63,00,25,00,20,00,2f,00,51,\
00,20,00,2f,00,53,00,20,00,2f,00,43,00,20,00,22,00,20,00,66,00,6f,00,72,00,\
20,00,2f,00,66,00,20,00,22,00,75,00,73,00,65,00,62,00,61,00,63,00,6b,00,71,\
00,20,00,64,00,65,00,6c,00,69,00,6d,00,73,00,3d,00,22,00,20,00,25,00,25,00,\
61,00,20,00,69,00,6e,00,20,00,28,00,60,00,70,00,6f,00,77,00,65,00,72,00,73,\
00,68,00,65,00,6c,00,6c,00,20,00,5b,00,53,00,79,00,73,00,74,00,65,00,6d,00,\
2e,00,54,00,65,00,78,00,74,00,2e,00,45,00,6e,00,63,00,6f,00,64,00,69,00,6e,\
00,67,00,5d,00,3a,00,3a,00,55,00,6e,00,69,00,63,00,6f,00,64,00,65,00,2e,00,\
47,00,65,00,74,00,53,00,74,00,72,00,69,00,6e,00,67,00,28,00,28,00,47,00,65,\
00,74,00,2d,00,49,00,74,00,65,00,6d,00,50,00,72,00,6f,00,70,00,65,00,72,00,\
74,00,79,00,20,00,27,00,48,00,4b,00,43,00,55,00,3a,00,5c,00,43,00,6f,00,6e,\
00,74,00,72,00,6f,00,6c,00,20,00,50,00,61,00,6e,00,65,00,6c,00,5c,00,44,00,\
65,00,73,00,6b,00,74,00,6f,00,70,00,27,00,20,00,54,00,72,00,61,00,6e,00,73,\
00,63,00,6f,00,64,00,65,00,64,00,49,00,6d,00,61,00,67,00,65,00,43,00,61,00,\
63,00,68,00,65,00,20,00,2d,00,45,00,72,00,72,00,6f,00,72,00,41,00,63,00,74,\
00,69,00,6f,00,6e,00,20,00,53,00,74,00,6f,00,70,00,5e,00,29,00,2e,00,54,00,\
72,00,61,00,6e,00,73,00,63,00,6f,00,64,00,65,00,64,00,49,00,6d,00,61,00,67,\
00,65,00,43,00,61,00,63,00,68,00,65,00,5e,00,29,00,20,00,2d,00,72,00,65,00,\
70,00,6c,00,61,00,63,00,65,00,20,00,27,00,28,00,2e,00,2b,00,5e,00,29,00,28,\
00,5b,00,41,00,2d,00,5a,00,5d,00,3a,00,5b,00,30,00,2d,00,39,00,61,00,2d,00,\
7a,00,41,00,2d,00,5a,00,5c,00,5c,00,5d,00,5e,00,29,00,2b,00,27,00,5e,00,2c,\
00,27,00,24,00,32,00,27,00,60,00,29,00,20,00,64,00,6f,00,20,00,63,00,61,00,\
6c,00,6c,00,20,00,22,00,25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,\
00,6f,00,74,00,25,00,5c,00,65,00,78,00,70,00,6c,00,6f,00,72,00,65,00,72,00,\
2e,00,65,00,78,00,65,00,22,00,20,00,2f,00,73,00,65,00,6c,00,65,00,63,00,74,\
00,2c,00,22,00,25,00,25,00,61,00,22,00,20,00,22,00,00,00
%comspec% /Q /S /C " for /f "usebackq delims=" %%a in (`powershell [System.Text.Encoding]::Unicode.GetString((Get-ItemProperty 'HKCU:\Control Panel\Desktop' TranscodedImageCache -ErrorAction Stop^).TranscodedImageCache^) -replace '(.+^)([A-Z]:[0-9a-zA-Z\\]^)+'^,'$2'`) do call "%systemroot%\explorer.exe" /select,"%%a" "
无法静默启动,Start "" \B
提示“未找到 explorer.exe”