Batch file to change Desktop background

2

I want to write a batch file that changes the Desktop background.

This is what I have so far:

Reg Add "HKCU\Control Panel\Desktop" /v Wallpaper /f /t REG_SZ /d   C:\background.jpg
Reg Add "HKCU\Control Panel\Desktop" /v WallpaperStyle /f /t REG_SZ /d 10

The first line works and changes the picture. But the 2nd line does not work.

I'm not sure what the /v /f /t /d switches mean.

Is there something wrong the my 2nd line?

user214577

Posted 2014-07-02T22:12:36.717

Reputation: 297

Run reg add /? to see what those all mean. – Mark Allen – 2014-07-02T22:42:42.913

oh okay so then all of those are valid but it is still not changing the style to fill which is what the 10 should be – user214577 – 2014-07-02T22:46:36.123

2

Well, I can't promise anything but when I searched on WallpaperStyle etc. I found this http://www.grouppolicy.biz/2011/03/best-practice-using-group-policy-to-configure-desktop-wallpaper-background/ which says among other things that it won't work until the user logs off and back on.

– Mark Allen – 2014-07-02T23:33:19.317

Ive been restarting after i run the script – user214577 – 2014-07-03T14:47:16.130

-1 you've made no attempt at troubleshooting.. e.g. see if it has written to the registry and see if making that change in the registry changes the wallpaper – barlop – 2015-12-27T18:47:36.450

Answers

-1

echo off
call :quiet>nul 2>&1
goto :EOF
:quiet

reg add "HKCU\Control Panel\Desktop" /v Wallpaper /f /t REG_SZ /d %windir%:\Desktop\wallpaper.bmp

reg add "HKCU\Control Panel\Desktop" /v WallpaperStyle /f /t REG_SZ /d 10

:: Make the changes effective immediately
:: %SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters

This works!

Jakob McElwain

Posted 2014-07-02T22:12:36.717

Reputation: 7

2Where's the difference to what the OP already posted? Your last line which is commented out? – nixda – 2015-09-15T13:43:56.767