I've been trying to set my wallpaper in Windows 10 by doing the following in a command prompt window:
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d wallpaper_directory /f
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
This works once, but then if I try to change the wallpaper soon after it, it does not work.
Am I doing something wrong or how do I fix this?
It is very simple go to C:\Users\yourname\AppData\Roaming\Microsoft\Windows\Themes here you find one image with name TranscodedWallpaper. Rename your image to TranscodedWallpaper and replace in this location(don't keep extension). Do same thing inside cachedFile folder also. After exicute RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True then your wallpaped got change
Apparently, "RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters" (with or without "1, True" or "2, True") leads to inconsistent results (at least on my PC). I found the following PowerShell script, that always works on my PC: https://c-nergy.be/blog/?p=15291, option 2:
#-------------------------------------------------------------------#
# ScriptName : SetWall.ps1 #
# Description : Force a Desktop wallpaper Refresh #
# Credits : Unknown (if you know original creator, let us know) #
# #
# Date : 01 July 2020 #
#-------------------------------------------------------------------#
#Modify Path to the picture accordingly to reflect your infrastructure
$imgPath="\\Domain.lab\netlogon\Wallpaper.png"
$code = @'
using System.Runtime.InteropServices;
namespace Win32{
public class Wallpaper{
[DllImport("user32.dll", CharSet=CharSet.Auto)]
static extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni) ;
public static void SetWallpaper(string thePath){
SystemParametersInfo(20,0,thePath,3);
}
}
}
'@
add-type $code
#Apply the Change on the system
[Win32.Wallpaper]::SetWallpaper($imgPath)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With