Change desktop wallpaper
Moderator: DosItHelp
Re: Change desktop wallpaper
I'm not sure how your question is relevant to the issue at hand. Have you attempted to install, and use the x86 version for the task, but it has failed to work?
Re: Change desktop wallpaper
Try to find the version for Windows Server 2003 x64. It may work for you.
Steffen
Steffen
-
- Posts: 43
- Joined: 12 Dec 2021 06:45
Re: Change desktop wallpaper
ok so idk if this is simple or not to add but I wanna do this but since I have two monitors I wanna change the wallpaper on each monitor and have them be different.
Is this a thing I can do?
Is this a thing I can do?
Re: Change desktop wallpaper
There's an IDesktopWallpaper COM interface (GUID {B92B56A9-8B55-4E14-9A89-0199BBB6F93B}) which is probably suitable to set the wallpaper per monitor.
https://learn.microsoft.com/en-us/windo ... pwallpaper
Currently I don't have time to wrap it into a PS code though. Perhaps somebody else did the job already.
Steffen
https://learn.microsoft.com/en-us/windo ... pwallpaper
Currently I don't have time to wrap it into a PS code though. Perhaps somebody else did the job already.
Steffen
Re: Change desktop wallpaper
OK here you go.
I used the script from #14 as a template. The new %set_monitor_wallpaper% macro expects 3 arguments with the first being the monitor index (refer to the remarks in the code).
At least Windows 8 is required as the IDesktopWallpaper interface is not supported on older versions.
I didn't have the chance to actually test the script with multiple monitors connected. So, if there's any issue please let me know.
Steffen
I used the script from #14 as a template. The new %set_monitor_wallpaper% macro expects 3 arguments with the first being the monitor index (refer to the remarks in the code).
At least Windows 8 is required as the IDesktopWallpaper interface is not supported on older versions.
Code: Select all
@echo off &: 𝖴𝖳𝖥⁃𝟪 𝗇𝗈 𝖡𝖮𝖬 ⵑ
:: This ^^ comment ^^ consists of non-ASCII.
:: NOTE: The Batch script itself must first be saved UTF-8 encoded, without BOM!
:: The comment (likewise any other non-ASCII sequence in the code) helps a text
:: editor to recognize the character set. It's kind of a BOM substitute and
:: avoids that the editor considers falling back to ANSI when the script is
:: opened again.
:: No further code update is required regardless of whether delayed variable
:: expansion is enabled or disabled.
::setlocal DisableDelayedExpansion
setlocal EnableDelayedExpansion
:: Capture the current console code page, then set the active code page to UTF-8
:: for some Unicode support. UTF-8 file names do only work because PowerShell is
:: involved which performs an implicit conversion to UTF-16.
for /f "delims=" %%i in ('chcp') do for %%j in (%%i) do set "oemcp=%%~nj"
>nul chcp 65001
:: Initialize the "set_monitor_wallpaper" macro.
call :init_set_monitor_wallpaper
:: Call the "set_monitor_wallpaper" macro, passing the monitor index, the option
:: and the path of the new image file.
:: The code was actually tested with this weird file name containing a few
:: special patterns in Batch/PowerShell, unbalanced bracketing, and non-ASCII
:: characters that require up to 4 UTF-8 bytes. The only change from the
:: original filename is the double percent sign, as is inevitable to represent
:: a single percent sign in string literals of a Batch script.
%set_monitor_wallpaper% 0 4 "%%{$_}}~@())[]]+-=! &'.';,#`^ÈЯ€𐍈.png"
echo return value: %errorlevel%
>nul chcp %oemcp%
pause
exit /b
:init_set_monitor_wallpaper
:: -- BRIEF --
:: Change the desktop wallpaper per monitor.
:: Requires Windows 8 or newer.
:: -- SYNTAX --
:: %set_monitor_wallpaper% mon opt "file"
:: mon Index of the monitor, with 0 for the primary monitor. Indices
:: greater than 0 define additional monitors.
:: Any value less than 0 will result in the wallpaper being set on
:: all monitors.
:: opt Option specifying the appearance of the wallpaper. This setting is
:: applied to all monitors.
:: Supported values:
:: 0 Center the wallpaper image in its original size, uncovered
:: area is filled with the background color.
:: 1 Tile the wallpaper image, starting in the upper left corner
:: of the screen.
:: 2 Stretch the image to cover the full screen, changing the
:: original aspect ratio if necessary.
:: 3 Stretch the image to fit horizontally or vertically,
:: retaining the original aspect ratio. Uncovered area is
:: filled with the background color.
:: 4 Stretch the image to cover the full screen, retaining the
:: original aspect ratio. The image might be cropped
:: horizontally or vertically.
:: 5 Span the wallpaper across multiple monitors.
:: When in doubt, use 4.
:: file Name of the new image file.
:: -- RETURN --
:: 0 The wallpaper has been updated.
:: 1 The wallpaper has not been updated. (E.g. the option is out of range or
:: the file doesn't exist.)
:: -- EXAMPLE --
:: %set_monitor_wallpaper% 0 4 "C:\wallpaper\example.jpg"
setlocal DisableDelayedExpansion
set set_monitor_wallpaper=for %%# in (1 2) do if %%#==2 (setlocal EnableDelayedExpansion^
%=% ^&set "p=^^!p:`=``^^!"^&set "p=^^!p:{=`{^^!"^&set "p=^^!p:}=`}^^!"^
%=% ^&for /f "tokens=1,2*" %%- in ("^^!p:$=`$^^!") do endlocal^&powershell.exe -nop -ep Bypass -c ^"^
%===% Add-Type '^
%=====% using System;using System.Runtime.InteropServices;using System.Threading;^
%=====% [Guid(\"B92B56A9-8B55-4E14-9A89-0199BBB6F93B\"),InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]^
%=====% interface IDW{^
%=======% void SetWp([MarshalAs(UnmanagedType.LPWStr)]string id,[MarshalAs(UnmanagedType.LPWStr)]string path);^
%=======% int _1();^
%=======% [return:MarshalAs(UnmanagedType.LPWStr)]string MonDevAt(int idx);^
%=======% int _3();int _4();int _5();int _6();^
%=======% void SetPos(int pos);^
%=====% }^
%=====% public class Wp{^
%=======% static int m;static int o;static string f;static bool r=true;^
%=======% static void Thd(){^
%=========% IDW w=(IDW)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(\"C2CF3110-460E-4FC1-B9D0-8A1C0C9CC4BD\")));^
%=========% try{w.SetPos(o);w.SetWp(m^^^^^^^<0?null:w.MonDevAt(m),f);}catch{r=false;}^
%=======% }^
%=======% public static bool Set(int mon,int opt,string file){^
%=========% m=mon;o=opt;f=file;^
%=========% Thread t=new Thread(Thd);^
%=========% t.SetApartmentState(ApartmentState.STA);
%=========% t.Start();
%=========% t.Join();^
%=========% return r;^
%=======% }^
%=====% }^
%===% ';^
%===% [IO.Directory]::SetCurrentDirectory($pwd);^
%===% exit -not [Wp]::Set(%%~-,%%~.,[IO.Path]::GetFullPath(\"%%~/\"))^"^
%=% ^&endlocal) else setlocal DisableDelayedExpansion^&set p=
endlocal&set "set_monitor_wallpaper=%set_monitor_wallpaper%"
if !!# neq # set "set_monitor_wallpaper=%set_monitor_wallpaper:^^!=!%"
exit /b
:: A few words about the macro code:
:: PowerShell requires that characters `, {, }, and $ are escaped with a
:: preceding backtick in a string literal. This needs to be done in the Batch
:: part of the macro. The PowerShell part wraps the IDesktopWallpaper COM
:: interface in C# code and calls its SetWallpaper, GetMonitorDevicePathAt, and
:: SetPosition methods (to shorten the macro, aliased as IDW, SetWp, MonDevAt,
:: and SetPos, respectively). The IDesktopWallpaper interface must be used from
:: within an implemented thread function running in a single-threaded apartment.
Steffen
Re: Change desktop wallpaper
to me, in order to change the wallpaper, these 3 commands were required from the forum, removing the wallpaper is also the part of changing and must work
1) reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v Wallpaper /t REG_SZ /d image.jpg /f
2) reg delete "%WallReg%" /v Wallpaper /f
3) rundll32.exe user32.dll,UpdatePerUserSystemParameters
but wallpaper still doesnt refresh, it has got mind of its own, sometime it works, sometime it doesnt
mostly it doesnt, it seemed to me windows was just stacking all the wallpaper changing commands somewhere
SET "WallReg=HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System"
and 1>nul 2>nul reg query "%WallReg%" /v "Wallspaper" why didnt errorlevel seem to work? it always gave errorlevel 0
reboot and log off worked.. but not what we want
next i tried
set q2=NIRCMDC-64.EXE
SET P11=sysrefresh
SET P12=sysrefresh environment
SET P13=sysrefresh policy
"%Q2%" %P11%
"%Q2%" %P12%
"%Q2%" %P13%
i finally found the meaning of what nirsoft-refresh was was that this thing didnt even work at all
next i tried
F5
sometimes it worked, sometime it didnt and must click the desktop to be active before pressing F5
one thing that 100% worked was maybe from my concoction
i killed the explorer
TASKKILL /F /IM Explorer.EXE
START "" /D "%SystemRoot%" /I /NORMAL Explorer.EXE
took about 1 sec to refresh but this robbed my
cursor position
mouse postion
active window
resets linkbar
going back to where i was took a longer time.
------------------------------
this part was added 10h later, my report is this.
reboot and log off worked. ...turned out... not really,
only power off worked, and log-off also had problems
and
putting these two lines in the startup.bat was a bit too harsh for the OS during the booting process
TASKKILL /F /IM Explorer.EXE
START "" /D "%SystemRoot%" /I /NORMAL Explorer.EXE
1) reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v Wallpaper /t REG_SZ /d image.jpg /f
2) reg delete "%WallReg%" /v Wallpaper /f
3) rundll32.exe user32.dll,UpdatePerUserSystemParameters
but wallpaper still doesnt refresh, it has got mind of its own, sometime it works, sometime it doesnt
mostly it doesnt, it seemed to me windows was just stacking all the wallpaper changing commands somewhere
SET "WallReg=HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System"
and 1>nul 2>nul reg query "%WallReg%" /v "Wallspaper" why didnt errorlevel seem to work? it always gave errorlevel 0
reboot and log off worked.. but not what we want
next i tried
set q2=NIRCMDC-64.EXE
SET P11=sysrefresh
SET P12=sysrefresh environment
SET P13=sysrefresh policy
"%Q2%" %P11%
"%Q2%" %P12%
"%Q2%" %P13%
i finally found the meaning of what nirsoft-refresh was was that this thing didnt even work at all
next i tried
F5
sometimes it worked, sometime it didnt and must click the desktop to be active before pressing F5
one thing that 100% worked was maybe from my concoction
i killed the explorer
TASKKILL /F /IM Explorer.EXE
START "" /D "%SystemRoot%" /I /NORMAL Explorer.EXE
took about 1 sec to refresh but this robbed my
cursor position
mouse postion
active window
resets linkbar
going back to where i was took a longer time.
------------------------------
this part was added 10h later, my report is this.
reboot and log off worked. ...turned out... not really,
only power off worked, and log-off also had problems
and
putting these two lines in the startup.bat was a bit too harsh for the OS during the booting process
TASKKILL /F /IM Explorer.EXE
START "" /D "%SystemRoot%" /I /NORMAL Explorer.EXE