Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Script to change wallpaper in windows 10?

I am trying to get a script to work that will change the default wallpaper for windows 10 because I will be deploying Win10 to all clients. When I run the batch code below, it is not changing the default wall paper. I see that the img0 file is in the correct directory C:\Windows\Web\Wallpaper\Windows but it is not changing the background. The code below is what I am using. I do get some access denied errors when trying to del C:\Windows\Web\4K\Wallpaper\Windows\img0_1366x768.jpg Access is denied.

takeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg
takeown /f C:\Windows\Web\4K\Wallpaper\Windows\*.*
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /Grant System:(F)
icacls C:\Windows\Web\4K\Wallpaper\Windows\*.* /Grant System:(F)
del c:\windows\WEB\wallpaper\Windows\img0.jpg
del /q C:\Windows\Web\4K\Wallpaper\Windows\*.*
copy %~dp0img0.jpg c:\windows\WEB\wallpaper\Windows\img0.jpg
copy %~dp04k\*.* C:\Windows\Web\4K\Wallpaper\Windows

Any ideas what I am doing wrong? TIA

like image 769
user1342164 Avatar asked Nov 05 '15 18:11

user1342164


People also ask

How to change wallpaper in Windows 10?

To change windows desktop wallpaper what we normally do is right click on the desktop and go properties and so on. But we can do the same by editing registry key using reg command from command line.

How to change wallpaper from command line?

Change windows wallpaper from command line bySrini To change windows desktop wallpaper what we normally do is right click on the desktop and go properties and so on. But we can do the same by editing registry key using reg command from command line.

How to set a BMP image as wallpaper in Windows 10?

We can set a bmp image as wallpaper. ≡ Menu Windows Commands, Batch files, Command prompt and PowerShell Change windows wallpaper from command line bySrini To change windows desktop wallpaper what we normally do is right click on the desktop and go properties and so on.

How to change Windows desktop wallpaper using registry key?

bySrini To change windows desktop wallpaper what we normally do is right click on the desktop and go properties and so on. But we can do the same by editing registry key using reg command from command line. The command is given below. reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d  wallpaper_path /f


2 Answers

Use Powershell to change the wallpaper. First, create a function like this:

Function Set-WallPaper($Value)
 {
    Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $value
    rundll32.exe user32.dll, UpdatePerUserSystemParameters
 }

Now call the function:

Set-WallPaper -value "path to wallpaper"
like image 67
Michael Palermo Avatar answered Oct 11 '22 06:10

Michael Palermo


I know this has already been answered, but if someone wants to do this in a batch file the icacls lines need to use /reset instead of the /grant... something like:

takeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /reset
copy %~dp0img0.jpg c:\windows\WEB\wallpaper\Windows\img0.jpg
copy %~dp04k\*.* C:\Windows\Web\4K\Wallpaper\Windows

should work (as long as it is being run by an Administrative account).

like image 22
Stephen Lee Parker Avatar answered Oct 11 '22 05:10

Stephen Lee Parker