I am trying to find a way of getting the "real path" of my actual desktop background. I use a slideshow and got many files (4k+) in the folder, some I want to delete the fast way.
What I've tried so far:
%AppData%\Microsoft\Windows\Themes\CachedFiles - only contains the actual image
%AppData%\Microsoft\Windows\Themes\TranscodedWallpaper - filepath and filename transcoded
HKEY_CURRENT_USER\Control Panel\Desktop\WallPaper - directs to the file above
HKEY_CURRENT_USER\Control Panel\Desktop\TranscodedImageCache - same as above
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers - only shows the copies of the files
My solution after some research:
With the transcoded path from
HKEY_CURRENT_USER\Control Panel\Desktop\TranscodedImageCache
I created a command
$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'
This one is working in a *.ps1 file or in powershell terminal:
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')`""
And tried adding it to the right click menu of windows background
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""
*the Read-Host is only to catch the error message
I get a error, can someone explain to me why or have a solution?
Error is "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
Thank you