Script to change wallpaper in windows 10 not working

11,797

The username you set in the Icacls command is wrong, you should be running as Admin, preferablly using the hidden Built-in Administrator Account if you get user-access denied, and use your username.

Secondlly, ensure to set the Wallpaper registry value of the current user, in HKEY_CURRENT_USER\Control Panel\Desktop registry key, that points to its current wallpaper.

Note that a logoff/restart is required under a limited language like Batch, which cannot notify about a system environment update.

Try this:

Set "oldWall=%WinDir%\Web\wallpaper\Windows\img0.jpg"
Set "newWall=%~dp0img0.jpg"
Set "WallPath=%WinDir%\Web\Windows\"

(
Takeown.exe /F "%WallPath%" /R /D S
Icacls.exe "%WallPath%" /Grant "%username%":"F" /T
Del /Q "%oldWall%"
Copy "%newWall%" "%oldWall%"
REG ADD "HKCU\Control Panel\Desktop" /V "Wallpaper" /T "REG_SZ" /D "%oldWall%" /F
)1>Nul

But if your purpose is to deploy a Windows ISO with a custom wallpaper set, then the prefered solution is to use WSIM (Windows System Image Manager) , which is included in the WAIK (Windows Automated Installation Kit) or also known as WADK (Windows Assessment and Deployment Kit), this way you can generate an AutoUnattend.xml file that should ship inside the ISO together the setup.exe file, this way you can modify a variety of default values when installing Windows, such as the default wallpaper for all users.

Share:
11,797

Related videos on Youtube

Jon
Author by

Jon

Updated on September 18, 2022

Comments

  • Jon
    Jon over 1 year

    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

    C:\Users\Administrator\Desktop\ReplaceWallpaper>(
    Takeown.exe /F "C:\WINDOWS\Web\" /R /D S
     Icacls.exe "C:\WINDOWS\Web\" /Grant "Administrator":"F" /T
     Del /Q "C:\WINDOWS\Web\wallpaper\Windows\img0.jpg"
    
    
        Copy "C:\Users\Administrator\Desktop\ReplaceWallpaper\img0.jpg" "C:\WINDOWS\Web\wallpaper\Windows\img0.jpg"
         REG ADD "HKCU\Control Panel\Desktop" /V "Wallpaper" /T "REG_SZ" /D "C:\WINDOWS\Web\wallpaper\Windows\img0.jpg" /F
        ) 1>Nul
        ERROR: File or Directory not found.
        C:\WINDOWS\Web" /Grant Administrator:F /T: The filename, directory name, or volume label syntax is incorrect.
    
    • Admin
      Admin over 8 years
      Did you try rebooting after changing the image file like this? My expectation would be that the file is read and loaded in to memory to be displayed as the background, changing the file directly (and doing nothing else) won't make the loaded copy change.
    • Admin
      Admin over 8 years
      Thanks I just rebooted but unfortunately no change
  • Jon
    Jon over 8 years
    Thank you this might be closer to what I need but I am getting an error. I added it above The filename, directory name, or volume label syntax is incorrect.