In my situation I have a huge folder of images that my wallpaper cycles thru. I get bored of some after awhile and want to delete them or sometimes I just wonder what the image name is because it can have the description of the image.
I built 2 scripts based on the feedback above - one to get the current image path and one to delete it. Only tested this on Windows 10.
Get the image path (getwallpaper.ps1)
$bytes=(New-Object -ComObject WScript.Shell).RegRead("HKEY_CURRENT_USER\Control Panel\Desktop\TranscodedImageCache")
$wallpaperpath=[System.Text.Encoding]::Unicode.GetString($bytes[24..($bytes.length-1)])
$wallpaperpath=$wallpaperpath.substring(0, $wallpaperpath.IndexOf("jpg", 0, $wallpaperpath.Length)+3)
write-output $wallpaperpath
Write-Host -NoNewLine 'Press any key to continue...';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
Delete the image (deletewallpaper.ps1)
$bytes=(New-Object -ComObject WScript.Shell).RegRead("HKEY_CURRENT_USER\Control Panel\Desktop\TranscodedImageCache")
$wallpaperpath=[System.Text.Encoding]::Unicode.GetString($bytes[24..($bytes.length-1)])
$wallpaperpath=$wallpaperpath.substring(0, $wallpaperpath.IndexOf("jpg", 0, $wallpaperpath.Length)+3)
write-output $wallpaperpath
Write-Host -NoNewLine 'Delete the file (y=yes)?'
$KeyOption = 'Y','N'
while ($KeyOption -notcontains $KeyPress.Character) {
$KeyPress = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
if($KeyPress.Character -eq 'y') { Remove-Item $wallpaperpath }
}
Write-Host
[Environment]::Exit(0)
I’m interested in the seemingly (but apparently not) base64-encoded registry entries. Why would Microsoft encode them like that? What’s to gain from hiding that basic information? – Synetech – 2017-01-11T02:00:44.327