No importa si lo intenté, no pude cambiar de manera confiable el fondo de pantalla con regedit y UpdatePerUserSystemParameters (incluso con bucles grandes), así que terminé usando powershell, funciona todo el tiempo.
Ver https://www.joseespitia.com/2017/09/15/set-wallpaper-powershell-function/
Set-Wallpaper.ps1 :
# use powershell.exe Set-Wallpaper.ps1 -Image "<path to image>"
param ([string]$Image="")
Function Set-WallPaper($Image) {
<#
.SYNOPSIS
Applies a specified wallpaper to the current user's desktop
.PARAMETER Image
Provide the exact path to the image
.EXAMPLE
Set-WallPaper -Image "C:\Wallpaper\Default.jpg"
#>
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class Params
{
[DllImport("User32.dll",CharSet=CharSet.Unicode)]
public static extern int SystemParametersInfo (Int32 uAction,
Int32 uParam,
String lpvParam,
Int32 fuWinIni);
}
"@
$SPI_SETDESKWALLPAPER = 0x0014
$UpdateIniFile = 0x01
$SendChangeEvent = 0x02
$fWinIni = $UpdateIniFile -bor $SendChangeEvent
$ret = [Params]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $Image, $fWinIni)
}
Set-WallPaper -Image $Image
HKCU\Control Panel\Desktop\TranscodedImageCache
antes de actualizar.