How could I find out the path to the current desktop image, for Windows 8

10

3

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

Scott Bennett-McLeish

Posted 2012-11-19T07:47:05.063

Reputation: 874

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

Answers

10

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.

Scott Bennett-McLeish

Posted 2012-11-19T07:47:05.063

Reputation: 874

In powershell, it's [System.Text.Encoding]::Unicode.GetString($bytes[24..($bytes.length-1)]), assuming $bytes contains the value of the key – NextInLine – 2015-02-10T21:39:32.517

2full 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] – Mark Harviston – 2016-09-10T21:54:55.840

2Just 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. – Nathan Taylor – 2014-01-20T20:31:31.337

3

  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.

Gilbert

Posted 2012-11-19T07:47:05.063

Reputation: 31

This is so straightforward and quick. I grabbed the file, changed the extension to .jpg and there it was. – valsidalv – 2015-11-06T18:42:35.140

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.

Karan

Posted 2012-11-19T07:47:05.063

Reputation: 51 857

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. – Scott Bennett-McLeish – 2012-11-20T22:56:53.233

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

Artanis

Posted 2012-11-19T07:47:05.063

Reputation: 171

2

For windows 8 or later you can launch this vbs file:

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

Or use this autohotkey script:

http://www.autohotkey.com/board/topic/111813-open-current-wallpaper-under-mouse-in-windows-8/

Both created by me.

Raveren

Posted 2012-11-19T07:47:05.063

Reputation: 675

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)

Chris Smith

Posted 2012-11-19T07:47:05.063

Reputation: 121

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

keinabel

Posted 2012-11-19T07:47:05.063

Reputation: 115