Refresh wallpaper in win7 via command line

2020-07-27 03:29发布

I want to refresh wallpaper in Windows 7 from command line. I'm setting wallpaper via reg.exe add.

rundll32.exe user32.dll,UpdatePerUserSystemParameters doesn't work (with 1,True or 1,False)

Requirements:

  1. It must refresh wallpaper immediately (no waiting)
  2. It must run from command line
  3. Default windows 7 command line is preferred. Writing a c++/VB/C# program is acceptable, but not as good as a default win7 cli solution.

4条回答
手持菜刀,她持情操
2楼-- · 2020-07-27 04:08

reg add works better using .bmp files

this requires users to execute rundll32 multiple? times

try a simple rename conversion picture.jpeg -> picture.bmp

查看更多
叛逆
3楼-- · 2020-07-27 04:10

Harder than I thought. Depending on your other needs you could eventually restart explorer.

taskkill /IM explorer.exe /F
explorer.exe

If you can call a program from the command line, you could also look at How to force Windows desktop background to update or refresh

查看更多
我欲成王,谁敢阻挡
4楼-- · 2020-07-27 04:17

Killing explorer is never a good idea, try this:

RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1, True
查看更多
Explosion°爆炸
5楼-- · 2020-07-27 04:21

At least on Windows 7 64-bit, I found that the rundll32.exe command worked, but just not every time. I don't have a theory of why, but my workaround was a .cmd file that calls it a lot of times. It's not elegant but it works every time. In our environment, we are launching it in the background async and invisible, so the fact that it runs for about 80 seconds just doesn't matter.

:: Do your stuff to apply the background .reg settings first
:: Then run UpdatePerUserSystemParameters many times
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1, True
timeout 1
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1, True
timeout 1
:: Etc. I have about 80 of them
查看更多
登录 后发表回答