2011-04
14
通过VBS更换桌面设置壁纸源码
作者:桑三 日期:2011-04-14
更换壁纸本来是一个很简单的问题,不过对于网吧或企业想统一桌面就不那么简单了。更换设置桌面壁纸的API好像是有的,今天桑三博客给大家分享的是用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"
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"
VBS做好后,再加入启动项,每次开机自动调用即可。
上一篇: 域用户账户登录后coreldraw12颜色失真解决办法
下一篇: 《裸婚时代》全集片花,你感动了吗?
文章来自: 源于网络
引用通告: 查看所有引用 | 我要引用此文章
Tags: 技术 电脑 批处理
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论