Windows shell background command

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.

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

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

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.

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:

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

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

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

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

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.

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!

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

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

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.

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.

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

Restarting the computer will fix it.

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, any command in command prompt will work in batch.

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

Читайте также:  Replace windows disk defragmenter

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.”

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

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”

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

Thank you. corrected the explanation.

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

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

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.

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

It works , Thanks

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

It shows me “too many command-line parameters”

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

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 😀

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

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!

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”

Читайте также:  Ubuntu usb install mac os

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

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

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

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

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

How to run a command in the background on Windows?

In linux you can use command & to run command on the background, the same will continue after the shell is offline. I was wondering is there something like that for windows…

5 Answers 5

I’m assuming what you want to do is run a command without an interface (possibly automatically?). On windows there are a number of options for what you are looking for:

Best: write your program as a windows service. These will start when no one logs into the server. They let you select the user account (which can be different than your own) and they will restart if they fail. These run all the time so you can automate tasks at specific times or on a regular schedule from within them. For more information on how to write a windows service you can read a tutorial online such as (http://msdn.microsoft.com/en-us/library/zt39148a(v=vs.110).aspx).

Better: Start the command and hide the window. Assuming the command is a DOS command you can use a VB or C# script for this. See here for more information. An example is:

You are still going to have to start the command manually or write a task to start the command. This is one of the biggest down falls of this strategy.

  • Worst: Start the command using the startup folder. This runs when a user logs into the computer
  • Cannot background command shell (non-meterpreter payloads) #8860

    Comments

    fsacer commented Aug 20, 2017 •

    Steps to reproduce

    1. run exploit on unix probably would be problem for windows too using normal exploit command
    2. press Ctrl + Z to try to background.

    Expected behavior

    It should background command session without closing msfconsole.

    Current behavior

    It closes msfconsole. What’s weird it shows do you want to background after it closes msfconsole.

    System stuff

    Metasploit version

    I installed Metasploit with:

    PS: I can background with exploit -z but still cannot interact with shell and then background it. Is there a way to rebind background key?

    Also another question I got root on vm manually using setuid nmap vuln. and command nmap —script script.txt but I couldn’t get to persist it through whole command session, is there a way to do that and make meterpreter shell root. I used the setuid_nmap exploit module but that one did not work for me.

    The text was updated successfully, but these errors were encountered:

    fsacer commented Aug 20, 2017

    As a workaround this works:

    • make sh file wrapper that catches SIGSTOP where msfconsole is located:
    • save as msfconsole.sh in /usr/bin/ directory
    • chmod +x msfconsole.sh

    fsacer commented May 14, 2018

    I think this can be closed for now since that was kinda fixed I guess.

    fsacer commented Jul 17, 2018 •

    This still seems to be happening on with cmd/unix/reverse payload:
    Framework: 4.17.2-dev-
    Console : 4.17.2-dev-

    1 of 1 task complete

    fsacer commented Jul 30, 2018

    can reproduce this also for powershell and windows reverse shell payloads on v4.17.4-dev-, also this might depend on desktop manager (specifically got this to happen on LXDE now and Gnome in the past)

    Читайте также:  Windows phone log error

    usama7628674 commented Jul 30, 2018 •

    @fsacer I tested in gnome desktop manager.

    usama7628674 commented Aug 1, 2018 •

    @fsacer Okay so it does background but not in a sense that I could use meterpreter commands,upon reinteracting with session it still goes back to powershell terminal.Only powershell commands work cuz it’s only powershell session.

    mbloms commented Sep 27, 2018

    I experienced this issue today. The SIGTSTP signal is not caught. When pushing Ctrl + Z the whole process is put in the background. I can get it back by using fg , and then I can put «y» to put the session in background.

    Tested with fish and bash on manjaro linux. Metasploit 4.17.5

    jeffmcjunkin commented Jul 7, 2019 •

    This normally still affects the latest msfconsole version:

    I like the workaround given above, with one tweak:

    The «$@» part means arguments given to msfconsole will still apply (background: https://stackoverflow.com/a/4824637/372377). I also gave the wrapper script the same name, but since it’s under /usr/local/bin/ (which is earlier in the $PATH ) means the wrapper script is called when running msfconsole .

    Since this breaks some post-exploitation functionality otherwise (there’s no way to exit powershell_shell inside meterpreter, for example, without Ctrl-Z), I’d recommend Rapid7 consider solving in the released versions.

    How can I execute a Windows command line in background?

    How can I execute a windows command line in the background, without it interacting with the active user?

    11 Answers 11

    Your question is pretty vague, but there is a post on ServerFault which may contain the information you need. The answer there describes how to run a batch file window hidden:

    You could run it silently using a Windows Script file instead. The Run Method allows you running a script in invisible mode. Create a .vbs file like this one

    and schedule it. The second argument in this example sets the window style. 0 means «hide the window.»

    This is a little late but I just ran across this question while searching for the answer myself and I found this:

    which, on Windows, is the closest to the Linux command:

    From the console HELP system:

    One problem I saw with it is that you have more than one program writing to the console window, it gets a little confusing and jumbled.

    To make it not interact with the user, you can redirect the output to a file:

    I suspect you mean: Run something in the background and get the command line back immediately with the launched program continuing.

    Which is the Unix equivalent of

    the above one is pretty closer with its Unix counterpart program &

    You can use this (commented!) PowerShell script:

    Save it as a .ps1 file. After enabling script execution (see Enabling Scripts in the PowerShell tag wiki), you can pass it one or two strings: the name of the executable and optionally the arguments line. For example:

    I confirm that this works on Windows 10.

    This is how my PHP internal server goes into background. So technically it should work for all.

    A related answer, with 2 examples:

    1. Sometimes foreground is not desireable, then you run minimized as below:

    call START /MIN «my mongod» «%ProgramFiles%\MongoDB\Server\3.4\bin\mongod.exe»

    Hope that helps.

    If you want the command-line program to run without the user even knowing about it, define it as a Windows Service and it will run on a schedule.

    You can see the correct way to do this in this link:

    Summarizing, you have to checkbox for ‘Run whether user is logged on or not’. Task user credentials should be enter after pressing ‘Ok’.

    I did this in a batch file: by starting the apps and sending them to the background. Not exact to the spec, but it worked and I could see them start.

    Оцените статью