此vbs适用于XP,但Windows 7有问题,除非您再次登录,否则墙纸更改不会生效。有什么方法可以立即重绘桌面吗?谢谢
设w= WScript.CreateObject("Wscript.Shell") filePath = "D:\wp.bmp“ w.RegWrite“HKCU\控制面板\桌面\墙纸”,filePath w.Run“%windir%\System32 32\RundL32.EXEuser32.dll,UpdatePerUserSystemParameters",1,True
发布于 2013-11-01 18:21:51
谢谢各位,正如你们所说的,Powershell pInvoke方法确实是我在网上找到的唯一可行的解决方案,所以我在这里复制它,以防有人陷入同样的问题。
Add-Type @"
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace Wallpaper
{
public class Setter {
public const int SetDesktopWallpaper = 20;
public const int UpdateIniFile = 0x01;
public const int SendWinIniChange = 0x02;
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int SystemParametersInfo (int uAction, int uParam, string lpvParam, int fuWinIni);
public static void SetWallpaper ( string path) {
SystemParametersInfo( SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange );
RegistryKey key = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true);
key.Close();
}
}
}
"@
[Wallpaper.Setter]::SetWallpaper('D:\wp1.bmp')https://stackoverflow.com/questions/19721554
复制相似问题