天天看点

服务器更换桌面壁纸,通过VBS更换桌面设置壁纸源码

服务器路径,只支持BMP格式

ServerPath="\\sangsan.cn\share$\bmp"

'本地文件名,将从服务器复制到本地后改名为这个文件名(包括完整路径)

BMPname="e:\back.bmp"

Set FSO = CreateObject("Scripting.FileSystemObject")

Set WshShell = WScript.CreateObject("WScript.Shell")

Set F = FSO.GetFolder(ServerPath)

Set FC = F.Files

Num = 0

ReDim bmp(FC.Count)

For Each F1 in FC

If UCase(FSO.GetExtensionName(F1.NAME)) = UCase("BMP") then

Num = Num + 1

bmp(Num) = F1.Path

End If

Next

Randomize

FSO.CopyFile bmp(Int(Num * Rnd + 1)),BMPname,True

WshShell.RegWrite "HKEY_CURRENT_USER\Control Panel\Desktop\TileWallpaper","0","REG_SZ"

WshShell.RegWrite "HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper",BMPname,"REG_SZ"

WshShell.RegWrite "HKEY_CURRENT_USER\Control Panel\Desktop\WallpaperStyle","2","REG_SZ"

WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ListviewShadow","1","REG_DWORD"

'如果桌面图标未透明,需要刷新组策略,如果已经透明,只需要刷新桌面

WshShell.run "gpupdate /force",0

'WshShell.run "RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters"