It is writen in vbscript to use run cscript script-name.vbs or set by GPO
I had kept the background images at a location named according to resolution like bg-1024.jpg, bg-1280.jpg, bg-1440.jpg ___________________________________________________________________
Dim strComputer
strComputer = "."
' Prepare WMI Connection
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
' Query WMI
Set getPixelsWidth = objWMIService.Execquery("Select * from CIM_VideoController")
' Get the Horizontal Resolution
strPixelWidth = getPixelsWidth.ItemIndex(0).CurrentHorizontalResolution
' Prepare filename for background wallpaper
strWallPaper = "\\x.x.x.x\usrdata\commonfiles\bg-" & strPixelWidth & ".jpg"
' Setting the wallpaper
Dim strWallPaper
Dim wshShell
Dim sUserName
Set wshShell = WScript.CreateObject("WScript.Shell")
sUserName = wshShell.ExpandEnvironmentStrings("%USERNAME%")
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sWinDir = oFSO.GetSpecialFolder(0)
sWallPaper = strWallPaper
' update in registry
oShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", sWallPaper
' let the system know about the change ( looped few times as always does'nt work first time )
For i = 0 to 15
oShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", True
wscript.echo i
Next
___________________________________________________________________
Best Regards.
No comments:
Post a Comment