The operating system I am using is Windows 10. I would like to change the album for the desktop wallpaper and lock screen slideshow by using a script or other programmatic means. I've looked into changing regedit settings but I couldn't find anything in regedit that directly referenced the album directory.

So far I've looked at HKEY_CURRENT_USER\Control Panel\Desktop and found that the current wallpaper picture is stored in %APPDATA%\Microsoft\Windows\Themes\TranscodedWallpaper and the elements of the slideshow is encoded in slideshow.ini which is a hidden file in that directory.

Again I would like to find a way to change this programmatically.

  • Which is it you are using? Windows 8, 8.1, or 10?
    – Insane
    Nov 30, 2015 at 22:44
  • @Insane I would like to know how to do it on all of those operating systems. But at least one is a good start. Dec 2, 2015 at 4:41
  • You should specify which you are using now and if you do get an accepted answer which doesn't work on another OS, you should ask a new question with this information.
    – Insane
    Dec 2, 2015 at 4:42
  • 1
    I am using Windows 10. Dec 2, 2015 at 4:48

3 Answers 3


So...I am using Windows 7. For the moment, the following seems to be working for me:

First you want to set up the slideshow as you want it, then go and save a backup of the file


As far as I can tell, this encodes the album folder path. There may be a way to build your own, but at this point I don't know.

I am using powershell. My powershell does the following:

Define a function to set the wallpaper based on the code here:

Add-Type @"
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace Wallpaper {

   public class Setter {
      public const int SetDesktopWallpaper = 20;
      public const int UpdateIniFile = 0x01;
      public const int SendWinIniChange = 0x02;

      [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
      private static extern int SystemParametersInfo (int uAction, int uParam, string lpvPara, int fuWinIni);

      public static void SetWallpaper (string path) {

         SystemParametersInfo(SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange);

         RegistryKey key = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true);

         //"Fit" style
         key.SetValue(@"WallpaperStyle", "6");
         key.SetValue(@"TileWallpaper", "0");



The total code is probably too long, but the gist is as follows:

Set Wallpaper from Picture to Slideshow

  1. Set the Wallpaper path to "" using the above function
  2. Copy the backed up slideshow.ini file back into that directory
  3. Stop-process -name explorer
  4. Sleep 1 sec, and start up explorer only if it hasn't automatically restarted

Set Wallpaper From Slideshow to Single Picture

  1. Delete the following two files if they exist:
  1. Set the wallpaper path using the above function
  2. Stop-process -name explorer
  3. Sleep 1 sec, and start up explorer only if it hasn't automatically restarted

Regarding the encoding of the slideshow.ini file: according to this forum conversation, the encoded field is a "uuencoded PCIDLIST_ABSOLUTE struct". I haven't looked into this but maybe someone can figure out how to create them.

Regarding killing explorer. It takes a few seconds on my machine for explorer to start up the slideshow after restarting but as far as I can tell it seems to work consistently. I've tried several alternatives but I couldn't figure out a cleaner way to make the desktop refresh and grab the new settings. I can see in SysInternals procmon when explorer.exe reads some of the relevant registry entries. It looks like it is during-ish or after-ish initializing the system tray.

I don't know how bad killing explorer semi-frequently is for your system. Maybe it's very bad? If you find a better way, please share. :)

  • If you can post your full code (or a link to it if it is huge), that will be appreciated! Jan 18, 2021 at 19:47
  • 1
    Okie dokie, it's been several years since I've used this code, but here is a gist of all my wallpaper/screen orientation/theme/lockscreen chicanery.
    – xdhmoore
    Jan 19, 2021 at 3:46
  • 1
    Thanks so much for the code, and for teaching me a new English word! :) Jan 19, 2021 at 9:34
  • Is there a way with PS to change the slideshow DIR and not just a single image? Aug 2, 2023 at 10:11
  • @KalamalkaKid It's been a while but I think you'd have to create or maybe templatize the slideshow.ini file. Or just switch between two prebaked files like in the other answer
    – xdhmoore
    Aug 2, 2023 at 16:03

I know this post is a bit old but helped me a lot. I had two picture folders and wanted to switch between them easily without going into windows settings.

According to previous post, I generated two "slideshow.ini" files(slideshow.ini and slideshow2.ini) for each of my picture folders. Then using a batch file I simply swapped the names of the files, deleted the Transcoded file and restarted Windows Explorer.

As a result instant folder change for my wallpaper with one click on the batch file. I am on windows 11.

Here is the small code of the batch file if somebody is interested:

cd %APPDATA%\Microsoft\Windows\Themes\

attrib -h "slideshow.ini"
attrib -h "slideshow2.ini"

ren "slideshow.ini" "slideshow3.ini"
ren "slideshow2.ini" "slideshow.ini"
ren "slideshow3.ini" "slideshow2.ini"

del "Transcoded_000"
del "Transcoded_001"
del "TranscodedWallpaper"

attrib +h "slideshow.ini"
attrib +h "slideshow2.ini"

taskkill /F /IM explorer.exe
start explorer.exe
  • 1
    I like this method, but wish there was a way to do this without killing explorer to make the changes visible. Aug 2, 2023 at 8:56

You can run an AutoHotkey 2 script to change the settings by automating the user interface, using UIA-v2.

Here's a AutoHotKey script for Windows 11 that will open the settings window, switch to Slideshow mode, choose the folder specified on the commandline, and then close settings.

To run this, you need to:

  • Install AutoHotkey 2 (you can choco install -y autohotkey.portable) - this script will not work with AutoHotkey v1
  • Obtain UIA-v2 following their instructions
  • Save the below script into a file like set-desktop-slideshow-folder.ahk
  • Adjust the first include line to specify the path to the UIA library if required
  • Run autohotkey set-desktop-slideshow-folder.ahk C:\absolute\path\to\desired\backgrounds\folder

This does cause windows to pop up, which might be a little irritating

#include UIA-v2\Lib\UIA.ahk
if (A_Args.Length < 1) {
    MsgBox("Please pass the desired folder on the commandline")
desiredFolder := A_Args[1]
if (not InStr(FileExist(desiredFolder), "D")) {
    MsgBox("Folder " desiredFolder " does not exist or is not a folder")
settings_window := WinExist("Settings")
if (settings_window != 0) {
    settingsEl := UIA.ElementFromHandle(settings_window)
    backgroundMode := settingsEl.WaitElement({AutomationId: "SystemSettings_Personalize_Background_ChooseBackground_ComboBox"})
    ; backgroundMode.Highlight()
    chosenMode := backgroundMode.FindElement({ClassName: "TextBlock"})
    if (chosenMode.Name != "Slideshow") {
        OutputDebug("Need to switch mode to slideshow; currently " chosenMode.Name)
        slideshowMode := settingsEl.WaitElement({Name: "Slideshow"})
        ; slideshowMode.Highlight()
        While (backgroundMode.Length > 1) {
        chosenMode := backgroundMode.FindElement({ClassName: "TextBlock"})
        if (chosenMode.Name == "Slideshow") {
            OutputDebug("Successfully switched mode to Slideshow")
        } else {
            OutputDebug("Failed to switch mode; it remains " chosenMode.Name)
    } else {
        OutputDebug("Already in slideshowMode; not switching")
    browseButton := settingsEl.FindElement({AutomationId:  "SystemSettings_Personalize_Background_SlideshowSource_Button"})
    picker_window := WinExist("Select Folder")
    tries := 0
    while (picker_window == 0) {
        tries += 1
        if (tries >= 20) {
            MsgBox("Folder selection failed after " tries " tries")
        Sleep 250
        picker_window := WinExist("Select Folder")
    pickerHost := UIA.ElementFromHandle(picker_window)
    folderName := pickerHost.WaitElement({ClassName: "Edit", Name: "Folder:"})
    folderName.Value := desiredFolder
    chooseButton := pickerHost.WaitElement({ClassName: "Button", Name: "Choose this folder"})
    closeButton := settingsEl.FindElement({AutomationId: "Close"})
} else {
    MsgBox("Didn't find Settings window")

You must log in to answer this question.

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