159

There is another question on here that allows users to find the path to their current background image through a cmd command.

How could I find out the path to the current desktop image?

In Windows 10 this no longer works. It only returns the first image in the folder, it does not change with the backgrounds as they transition. I need a similar command that returns the path(s) to the current image on the desktop background(s) that actually works in Windows 10 if one exists.

cujo
  • 1,650

8 Answers8

261

Built-in wallpapers

A copy of the current wallpaper can be found by entering one of the below paths in Windows File Explorer address bar.

Path 1 -
%AppData%\Microsoft\Windows\Themes\CachedFiles


Path 2 -
%AppData%\Microsoft\Windows\Themes\TranscodedWallpaper

Note: TranscodedWallpaper does not have a file extension, even though it is a JPEG image file.
To view the image, right click on the file and use "Open With" option; or select the image and press Enter.
This will bring up the "Select an app to open..." or "How do you want to open this file?" dialogue box. Any popular image viewer should work - such as the "Windows Photo Viewer" or the "Photos" app.
Alternatively, drag and drop the file into a Firefox tab or mspaint window to view/edit.

Note for Windows 10/11: The above locations have limitations. For example, if the wallpaper you're looking for is no longer visible in the 'Background' tab in the Settings app, you can't recover it. It will work for your last five wallpapers but nothing older. 1


Path 3: Default Windows wallpapers -
%SystemRoot%\Web

Check in one of the below folders -

  • "4K" for 4K wallpapers,
  • "Screen" for lock screen backgrounds,
  • "touchkeyboard" for colorful abstract backdrops in Windows 11 2
  • "Wallpapers" for default Windows wallpapers

Path 4: Wallpapers from installed themes (Aero, etc.) -
%SystemRoot%\Resources\Themes

Path 5 [wallpapers from per-user installed themes (including pre-installed themes from OEM)] -
%LocalAppData%\Microsoft\Windows\Themes

Path 6: If Windows Photo Viewer was used to set desktop wallpaper -
%AppData%\Microsoft\Windows Photo Viewer\


Slideshow or user specific wallpapers

If the wallpaper is set by Windows Slideshow or manually set by a user, try one of the below scripts.

The code will attempt to extract the original location of the image by decoding binary data from below key in the Windows Registry .
Key Name: HKEY_CURRENT_USER\Control Panel\Desktop
Value Name: TranscodedImageCache

Windows Slideshow -
Windows 11 Slideshow

Manually set wallpaper - e.g., right click on image file and select "Set as desktop background"
Set as desktop background


Script 1 - vbs

  • To decode the registry key and view the image in Windows Explorer, follow the instructions listed on ElevenForum.com; or
  • Open Notepad to save below code in a .vbs file and run it.

Only ASCII compatible. Read the warning written below the code.

The contents of vbs file 5 -

Const HKCU = &H80000001 'HKEY_CURRENT_USER

sComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" _ & sComputer & "\root\default:StdRegProv")

sKeyPath = "Control Panel\Desktop" sValueName = "TranscodedImageCache" oReg.GetBinaryValue HKCU, sKeyPath, sValueName, sValue

sContents = ""

For i = 24 To UBound(sValue) vByte = sValue(i) If vByte <> 0 And vByte <> "" Then sContents = sContents & Chr(vByte) End If Next

CreateObject("Wscript.Shell").Run "explorer.exe /select,""" & sContents & """"

Note: The vbs didn't work for me when I first set up the Slideshow, but it worked after changing to the next image in the Slideshow.
Warning: This vbs code does not work if the file name contains non-ASCII characters, i.e., if Unicode characters (like Δ, Й, ק ,م, ๗, あ, 叶, 葉, 말) are present in the file name, then the vbs code above will fail to locate the image in Windows Explorer.


Script 2 - PowerShell 8

ASCII + Unicode compatible

  • Option A: Run code via PowerShell window

    • Open Windows PowerShell using the Start menu or Win + X shortcut.
    • Paste below code and press Enter.
      $TIC=(Get-ItemProperty 'HKCU:\Control Panel\Desktop' TranscodedImageCache -ErrorAction Stop).TranscodedImageCache
    • Paste below code (a second time) and press Enter.
      [System.Text.Encoding]::Unicode.GetString($TIC) -replace '(.+)([A-Z]:[0-9a-zA-Z\\])+','$2'

    Location of the wallpaper will displayed.

Wallpaper path in PowerShell window

  • Option B: Save code as .ps1 file and run

    • Open 'Notepad' and paste the three lines of code mentioned below
    • Save the new document as Wallpaper_path.ps1 file [under 'Save as type:' select "All types" - see screenshots below]
    • Go to the file, right click on the file and select "Run with PowerShell"

    Location of the wallpaper will be generated and copied to clipboard.

$TIC = (Get-ItemProperty 'HKCU:\Control Panel\Desktop' TranscodedImageCache -ErrorAction Stop).TranscodedImageCache
$result = [System.Text.Encoding]::Unicode.GetString($TIC) -replace '(.+)([A-Z]:[0-9a-zA-Z\\])+','$2'
Set-Clipboard -Value $result

Save as ps1 file Run ps1 file


Script 3 - AHK

ASCII + Unicode compatible

  • Download and install AutoHotkey
  • Open Notepad and save below code as .ahk file
  • Run .ahk file
  • Press Win + W and the location of the wallpaper will be displayed as a message box.
#Requires AutoHotkey v2.0
#SingleInstance force

; #HotIf WinActive("ahk_class WorkerW ahk_exe explorer.exe") ; commented out - enable shortcut on desktop only

#W::{ ; Win + W MsgBox "WallpaperPath_v4`n" WallpaperPath_v4(ThisHotkey),, 262144 ; 262144 = Always-on-top }

; #HotIf

;------- ; User-defined functions ; below code was modified from v1 - https://gist.github.com/raveren/bac5196d2063665d2154#file-aio-ahk-L741 ; This source has code for multi-monitor setups that is not included here. ; Look for openWallpaperUnderMouse() and getMonitorUnderMouse() functions over there if you need it.

WallpaperPath_v4(key := A_ThisHotkey) {

; Read the binary value from the registry regBinary := RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "TranscodedImageCache") ; 1600 characters ; alternative: regBinary := RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "TranscodedImageCache_000")

; remove first 48 characters and create array regArr := StrSplit(SubStr(regBinary, 49))

; variable that stores path ConvString := ""

Loop regArr.Length { If Mod(A_Index, 4) != 0 ; generate char every 4th Loop, when mod() = 0 (division remainder) Continue ; skip rest of the Loop if A_Index is 1 2 3 (not 4) 5 6 7 (not 8) 9… Else ; in Loop 4, 8… reposition characters as Chr("0x" [3] [4] [1] [2]), Chr("0x" [7] [8] [5] [6])… and so on char := Chr("0x" regArr[A_Index - 1] regArr[A_Index] regArr[A_Index - 3] regArr[A_Index - 2])

If char = &quot;&quot;            ; char := Chr(&quot;0x&quot; 0 0 0 0) consecutive zeroes results in empty string
    Break               ; End Loop
Else ConvString .= char ; add generated string to path
}

If FileExist(ConvString) Return ConvString ; Return path to desktop wallpaper Else { MsgBox key ":: WallpaperPath() is not valid!nConverted String: &quot; ConvString &quot;nnTranscodedImageCache:n" regBinary,, 262144 ; 262144 = Always-on-top Exit } }

MsgBox containing wallpaper path

For other iterations of this code, visit this AHK v2 script on GitHub.


Bonus Info

If you are looking for the location of Lock Screen images, visit this SuperUser question.

Note on 3rd party apps
When 3rd party apps like John's Background Switcher are used to manage desktop backgrounds (which I used on my older Win10 PC), they typically provide an option to view the current/previous desktop background (if set by the app itself). Check the app's help file to know more.

  • To activate Windows Photo Viewer in Windows 10, visit this article on HowToGeek.
  • To download default wallpapers from every Windows version, visit this article on XDA.
  • To download every Bing wallpaper in 4K, visit this page on GitHub.
xypha
  • 4,890
32

I have Windows 10, version 1709. One of the other answers got me looking in the registry and I found exactly what I needed in clear text at

HKEY_CURRENT_USER\Control Panel\Desktop\WallPaper

No decoding needed.

Jim
  • 535
13

Windows 8 and 10 still store the original path of the current background image - rather than the cached / transcoded file as in xypha's answer:

HKEY_CURRENT_USER\Control Panel\Desktop\TranscodedImageCache

Microsoft doesn't want things to be easy though: this isn't plain text so you have to decode it from binary.

The Winhelponline website has compiled a couple of scripts (VBA and PowerShell) which can print the image name, and launch Explorer to point to the image file.

http://www.winhelponline.com/blog/find-current-wallpaper-file-path-windows-10/

Iain S
  • 303
7

To get the "Transcoded" PATH in cleartext, do this in PowerShell:

$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'
not2qubit
  • 2,651
  • 4
  • 34
  • 45
2

I found the Windows 10 (theme) background folder here:

%USERPROFILE%\AppData\Local\Microsoft\Windows\Themes\RoamedThemeFiles\DesktopBackground

(I use the built-in themes of Windows 10 so maybe this doesn't work every time.)

tkalvin
  • 161
2

It hasn't been mentioned yet, but in the Registry Editor, you can navigate to:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers

To find a list of filenames and locations of your current as well as the past few background images that you have used.

1

You don't explain exactly what is the FINAL purpose of this, so I can give some tips here based on a guess: you want to change your wallpaper in certain conditions (for example, one wallpaper every time you restart your computer) or to use a custom file as wallpaper.

In Windows 7 the wallpaper was usually found in %AppData%\Microsoft\Windows\Themes\TranscodedWallpaper.
In Windows 10 you will find it in %AppData%\Microsoft\Windows\Themes\CachedFiles.

You can also interrogate the registry at

HKEY_CURRENT_USER\Control Panel\Desktop\TranscodedImageCache

but note the warnings below about programs that are NOT writing a file to disk!

If you want to build your own CMD script, this might be unreliable IF you set the wallpaper not from Windows but from an external program. For example, if I see a nice image in my browser, I set it as wallpaper directly from there. Same for IrfanView. I can easily name another 10 popular programs that could change the wallpaper to a custom path.

Note that some programs are changing the wallpaper without actually writing a file to disk. This can be done by hooking to the Microsoft Windows Desktop window and drawing directly on its canvas. This is how GIF/AVI animations are drawn on desktop.

There is another issue if you build your own script: How to you handle images that don't have same aspect ratio as your desktop, or when desktop resolution changes?

The solution (if I guessed your problem correctly) would be to use a program like John's Background Switcher or BioniX Desktop Background Changer. The latter is much more customizable and can be controlled via command line. It also has auto-detection to detect the best way to resize the image (fill/fit/tile). BioniX can also draw GIF without writing anything to disk (as explained above).

A even better way would be to use the "Lock on folder" option. Set BioniX to change your wallpaper every 60 seconds (don't worry, you won't see a new wallpaper every 60 seconds since you will use only one file). Set BioniX to lock on any folder (let's say C:\Wallpapers). Inside that folder you put a single file called something like My Wallpaper.jpg. BioniX will use that file as wallpaper every 60 seconds. Now, every time you want to change the wallpaper you replace the old My Wallpaper.jpg with your new file. BioniX will see the change you have done to the folder and apply the new file (within 60 seconds).


Let us know what you want to achieve with your script to get a better solution.

GoUkraineGo
  • 2,171
1

To complete xypha's answer I have to note that:

Windows 10 Personalize Settings shows 5 wallpapers used recently, IF THE ORIGINAL FILES STILL EXIST but, if you set your wallpaper using the Windows 10's Photos app, a copy of the image will be kept in this location (only 1 photo will be kept):

%LOCALAPPDATA%\Packages\Microsoft.Windows.Photos_8wekyb3d8bbwe\LocalState\PhotosAppBackground\

Similarly, for the Lock Screen background:

%LOCALAPPDATA%\Packages\Microsoft.Windows.Photos_8wekyb3d8bbwe\LocalState\PhotosAppLockscreen\

If the directories do not exist, It's most likely that for each version of Windows, the Photos app version might be different so mind the trailing characters in this folder name: Microsoft.Windows.Photos_8wekyb3d8bbwe, look around and in the parent directory (%LOCALAPPDATA%\Packages\) and you will find the folder related to the Photos app Microsoft.Windows.Photos_RandomCharacters. My version of Windows 10 is 1803.

Shayan
  • 1,893