Set Wallpaper

download Set Wallpaper

of 1

Transcript of Set Wallpaper

'Set the wallpaper strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_VideoController",,48 ) Set WshShell = WScript.CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environment("Process") Set objFSO = CreateObject("Scripting.FileSystemObject") WinPath = WshSysEnv("SystemRoot") & "\YourWallpaper.bmp" If Not objFSO.FileExists(winpath) then 'If the file does not exist then copy it For Each objItem in colItems sourcePath = "\\path\here\" rightSize = "NameHere" & objItem.CurrentHorizontalResolution & "x" & objItem.Cur rentVerticalResolution & ".bmp" objFSO.CopyFile sourcePath & rightSize, WSHShell.ExpandEnvironmentStrings ("%Sys temRoot%") & "\NameYourWallpaper.bmp", overwrite = True Next End If '******************************************************************************* ***************************************************************** 'Set Wallpaper Bitmap to Default Set WshShell = CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") sWinDir = objFSO.GetSpecialFolder(0) sWallPaper = sWinDir & "\NameYourWallpaper.bmp" ' update in registry WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", sWallPaper WshShell.Regwrite "HKCU\Software\Microsoft\Internet Explorer\Desktop\General\Wal lpaper", sWallPaper WshShell.Regwrite "HKCU\Software\Microsoft\Internet Explorer\Desktop\General\Bac kupWallpaper", sWallPaper ' let the system know about the change WshShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParam eters", 1, True

'********************************************** Dim WshShell Set WshShell = WScript.CreateObject("Wscript.Shell") WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", mybitmap.bmp WshShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters", 1, False Set WshShell = Nothing