如何在Windows 10上从Windows命令提示符设置壁纸?

时间:2017-10-27 23:11:27

标签: cmd

我一直在尝试通过在命令提示符窗口中执行以下操作在Windows 10中设置我的壁纸:

reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d wallpaper_directory /f

RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

这可以使用一次,但如果我尝试在它之后不久更改壁纸,它就不起作用。

我做错了什么或如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

这非常简单,请转到C:\ Users \您的名称\ AppData \ Roaming \ Microsoft \ Windows \ Themes,在这里您可以找到一张名为TranscodedWallpaper的图像。将您的图片重命名为TranscodedWallpaper并在此位置替换(不要保留扩展名)。在cachedFile文件夹内也做同样的事情。 淘汰 RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters,1,True 之后,您的挂墙便有了变化

答案 1 :(得分:0)

显然,“RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters”(带或不带“1, True”或“2, True”)会导致不一致的结果(至少在我的电脑上)。我发现以下 PowerShell 脚本始终适用于我的 PC:https://c-nergy.be/blog/?p=15291,选项 2:

#-------------------------------------------------------------------#
# ScriptName : SetWall.ps1                                          #
# Description : Force a Desktop wallpaper Refresh                   #
# Credits  : Unknown (if you know original creator, let us know)    #
#                                                                   #
# Date : 01 July 2020                                               #
#-------------------------------------------------------------------#

#Modify Path to the picture accordingly to reflect your infrastructure
$imgPath="\\Domain.lab\netlogon\Wallpaper.png"
$code = @' 
using System.Runtime.InteropServices; 
namespace Win32{ 
    
     public class Wallpaper{ 
        [DllImport("user32.dll", CharSet=CharSet.Auto)] 
         static extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni) ; 
         
         public static void SetWallpaper(string thePath){ 
            SystemParametersInfo(20,0,thePath,3); 
         }
    }
 } 
'@

add-type $code 

#Apply the Change on the system 
[Win32.Wallpaper]::SetWallpaper($imgPath)
相关问题