伺服器路徑,隻支援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"