≡ Menu

Change windows wallpaper from command line

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

For example to set the image E:\photos\image1.bmp as the wall paper we need to run the command as below.

reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d E:\photos\image1.bmp /f

After editing the registry key we need to run the below command to make the change take effect immediately.

RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

Note that this method works only for bmp images. If you have .jpg or .jpeg images you can’t set them as wallpaper from command line. You can use the Desktop settings UI to set a .jpg or .jpeg file as wallpaper.

42 comments… add one
  • Anonymous

    This won't work for two reasons:
    1) file needs to be a bmp
    2) writing the registry doesn't cause the change to happen, you need to do something like:

    RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

    as well

    • mixkie

      It also works for “.jpg” as well. I’ve tried it. I think the real problems that need to be fix is:
      + remove “/f” from the first command
      + add space after “dll” in the second command

  • Techblogger

    Thanks for the comment..will modify the post with these steps..

  • Anonymous

    Hello, it appears this command does not work for me, I honestly don't know why…the reason I want to do this is because my windows7 does not have the option to select an image as background when I right click and look at the pop up menu….Any help or suggestions will be appreciate. Thanks

    • ankit

      I think you have n’t yet activated your windows copy. Just activate it, after that you can use this.

    • it dosent work for me toooooooooooooooooooooooooooooooooooooo

  • Techblogger

    Try doing it from Control panel -> Appearance and personalization -> Personalization.

    Were you trying to do this in RDP connection? Looks like desktop background can't be changed in remote desktop connections.

  • Anonymous

    My windows7 does not even have this personalization option, siriosly. I am also not using any RDP connection…Any other suggestions? …Is my windows7 screwed up, not installed correctly/fully? Thanks!

  • Anonymous

    you are using wiondows 7 starter! you cannot change backgound picture in windows 7 starter edition

  • Aleksandar

    Hello, I wonder why this update thing doesn’t work for me.

    RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

    The wallpaper is changed in the registry (I checked through regedit.exe) and also in Personalization the new image seems to show up.
    But I can’t get it to update immediately.

    Thanks in advance.

    • admin

      Looks like the rundll update command is not working in Windows 7. It works in XP. I could not find any other command to make the wall paper changes take effect immediately. However a logoff and login would change the wallpaper.

    • ITB

      add a space between dll, Up
      rundll32.exe user32.dll, UpdatePerUserSystemParameters

    • Restarting the computer will fix it.

    • Skyphoenix

      What worked for me is running this command multiple times in a row (like 6 times) and then it worked (notice the space after the comma):
      rundll32.exe user32.dll, UpdatePerUserSystemParameters

  • Aleksandar

    Forgot to mention, I’m using Window 7 Pro and just locally no remote connections. I want to make this work in a batch script where some conditions are changed :)

    • You can't track me

      You can, any command in command prompt will work in batch.

  • Keby Zlima

    There is two more keys:
    1) WallpaperStyle
    2) TileWallpaper.
    WallpaperStyle = 10 and TileWallpaper = 0 make walpaper filled
    WallpaperStyle = 6 and TileWallpaper = 0 make walpaper fited
    WallpaperStyle = 2 and TileWallpaper = 0 make walpaper stretched
    WallpaperStyle = 0 and TileWallpaper = 0 make walpaper centered
    WallpaperStyle = 0 and TileWallpaper = 1 make walpaper tiled

  • Louis

    I just tried the command:
    “reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /d C:\Users\Louis\Desktop\test.bmp /f”

    But only get the error:
    “ERROR: Invalid key name.
    Type “REG ADD /?” for usage.”

    • Mitch

      Change “HKEY_CURRENT_USER\Control Panel\Desktop”
      To “HKCU\Control Panel\Desktop” (You may need to retype out the quotes.

    • Cameron

      Yea same

    • B8Two

      The /f” should not be part of the Quotes for the path to the file to be clearer put the /f before /d and path.

      in your example;
      reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /f /d “C:\Users\Louis\Desktop\test.bmp”

  • Bram

    Hello, I suppose you changed image1.jpg to image1.bmp in the example code after the anonymous comment in January 2011, but you have not made that change in the explanation above the code, it still says image1.jpg.
    Thanks for this article anyway, when I searched for a how-to on this topic this was the result which best fitted what I wanted.
    And thanks to Keby Zlima for the explanation on the other codes.
    Best regards, Bram

    • Srini

      Thank you. corrected the explanation.

  • ahmed

    Before I reached the note that says that the image should be .bmp I was already testing on .jpg which did work for me.

  • Nivloc

    I used that code, it worked great. Once. Now it doesn’t do anything. Thoughts?

  • Xander

    I’m trying to get this working for remote support jobs. My plan is to export the existing Desktop hive as a backup, set up my own wallpaper during the session and then, when I’m done, import the saved hive back into place.

    Only problem is that (on Win10 at least), the Rundll32 command does nothing. Even after I’ve changed the wallpaper key, F5ing the desktop doesn’t show the new graphic even though it shows up in the registry in the exact same format as if I had edited it through the control panel.

    Argh.

  • Cameron

    Im using this in a bat file but it won’t work: try reg add /?

  • Nando

    It works , Thanks

  • Chris

    Thank you so much, you saved me a lot of work to figure out how to make the wallpaper centered and automated.
    Chris

  • maro

    It shows me “too many command-line parameters”

  • Anomymous

    For some reason, this only seems to work 5% of the time… Is there any way to make it work “consistently”?

    Here’s the code:
    reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /d %AppData%\Test_image.bmp /f
    RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters

    Note: I made it in a batch file, not directly into cmd, using it to create a program

  • Dany Gee

    This batch file solved it for me. It checks if it is before or after 20:00 o’clock. If past – sets night wallpaper if before – sets day wallpaper.
    The problem was it sometimes did work at 1st attempt, sometimes after 5th attempt. So I figured it out that the “dll line” should be repeated at least 5 times – now the code works everytime :D

    Add this batch script to your scheduler (at logon and at 20:01) and you will have automagic wallpaper changer based on the time of the day.

    @echo off
    setlocal enabledelayedexpansion
    set “Wtime=!time:~0,2!”
    if “!Wtime!” leq “20” reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /d “D:\MEGA\Obrazy\Tapety Desktop\mojave_dynamic\mojave_dynamic_8.jpeg” /f & goto done
    if “!Wtime!” geq “20” reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /d “D:\MEGA\Obrazy\Tapety Desktop\mojave_dynamic\mojave_dynamic_15.jpeg” /f & goto done
    :done
    timeout /t 5 >nul
    start “” /b RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters ,1 ,True
    start “” /b RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters ,1 ,True
    start “” /b RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters ,1 ,True
    start “” /b RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters ,1 ,True
    start “” /b RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters ,1 ,True
    endlocal

  • Peter Kionga-Kamau

    Win7 Ultimate. What I need to do is not change it but rather *remove* the wallpaper and make it a solid color (black). Does anyone know what the command would be for that? Thanks!

  • Diwakaran

    i had some issue in my office i cant change …
    it shows like “you can only import binary registry files from within the registry editor”

    please help me…

  • Annon

    reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /d C:\Users\BRIAFS\Desktop\1.png /f
    RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

    Powershell command WORKS

  • shmee

    Remove the backdrop by going in to Ease of access centre, click Make the computer easier to see, then tick the box Remove background images. You can then change the background colour by going in to Control Panel, Personalisation, Windows Color, and select the Desktop colour

  • Thomas

    uhh, ive been trying and playing around with this. it hasnt been changing the wallpaper. do i need to restart my computer??

  • rev0lver

    does not work for me on Windows 10, also tried other recommendations.

  • kerbal300

    it don’t work for me when I do like this —-> reg add “HKEY_CURRENT_USER\Control Panel\Desktop” /v Wallpaper /t REG_SZ /d “C:\Users\Me Lol\Pictures\Wallpaper.png” /f

    if you did this on the command Prompt, It don’t work on Windows 10

  • Keenan Yafiq

    can’t work?

    when restarting the computer just showing a black background.

  • MartyTheMVP

    it says it run successfully but the background never changed.

  • JOYAL JOSE

    Tried on Win 11 with png works fine.

Leave a Comment