11

Having recently upgraded to Windows 8, my script to retrieve the current desktop wallpaper image has broken.

For Windows 7, How could I find out the path to the current desktop image?, this works great. However, that registry key now always contains

C:\Windows\web\wallpaper\Windows\img0.jpg

What is the new registry key used for Windows 8?

I've found two possible solutions.

Firstly, this key contains what looks like a Base64 encoded path:

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers\Images\ID2

And then there is the "custom theme properties file" which also contains a "[SlideShow]" section which looks like Base64:

C:\Users\Scott\AppData\Local\Microsoft\Windows\Themes\Custom.theme
1
  • 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
    Jan 11, 2017 at 2:00

7 Answers 7

11

The two registry keys below both store the original path of the current wallpaper image:

HKEY_CURRENT_USER\Control Panel\Desktop\TranscodedImageCache
HKEY_CURRENT_USER\Control Panel\Desktop\TranscodedImageCache_000

They're in Unicode format, upon decoding that, one will have the full path to the current wallpaper image.

3
  • 3
    Just a clarification for anyone messing around with this: the value contains non-string data in first 24 bytes, and the remaining data is a Unicode encoded, null-terminated (\0) string. Happy parsing. Jan 20, 2014 at 20:31
  • In powershell, it's [System.Text.Encoding]::Unicode.GetString($bytes[24..($bytes.length-1)]), assuming $bytes contains the value of the key
    – NextInLine
    Feb 10, 2015 at 21:39
  • 2
    full twoliner powershell: $bytes=(New-Object -ComObject WScript.Shell).RegRead("HKEY_CURRENT_USER\Control Panel\Desktop\TranscodedImageCache_000"); $path=([System.Text.Encoding]::Unicode.GetString($bytes[24..($bytes.length-1)]) -split "\0")[0] Sep 10, 2016 at 21:54
6
  1. Go to Windows Run Command (WinLogo+R)
  2. Type in: %AppData%
  3. In the 'Roaming' folder, go to 'Microsoft', then 'Windwows', then 'Themes', and lastly 'CachedFiles'
  4. Copy the wallpaper file.
1
  • This is so straightforward and quick. I grabbed the file, changed the extension to .jpg and there it was.
    – valsidalv
    Nov 6, 2015 at 18:42
2

Check the HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper REG_SZ (string) value. This will show you the path to the TranscodedWallpaper.jpg currently in use.

1
  • Thank you! That pointed me to the correct registry location at least. I not only wanted the current wallpaper but the path to the original file (like Window 7 did), which is in the TranscodedImageCache entry. Nov 20, 2012 at 22:56
2

In Windows 8 and 8.1 (and, reportedly, 10), if you have set your wallpaper from Windows Picture Viewer (by opening a picture in Viewer and clicking "Set as desktop wallpaper" in the context menu), its location will be

%AppData%\Roaming\Microsoft\Windows Photo Viewer\Windows Photo Viewer Wallpaper.jpg
2

For Windows 8/10 or later you can launch this vbs file:

https://gist.github.com/raveren/ab475336cc69879a378b

Or use this autohotkey script:

https://gist.github.com/raveren/bac5196d2063665d2154 (look for "WIN+W")

Both created by me and support multiple monitors to open the wallpaper under the mouse cursor.

1

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)
1
  1. Go to C:\Users\<USERNAME>\AppData\Roaming\Microsoft\Windows\Themes.
  2. Create a copy of TranscodedWallpaper
  3. Rename the copy to <NAME>.JPG

Tested on Windows 10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .