[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 632
  • Last Modified:

WSH change wallpaper.

Is there a way change the wallpaper on a desktop using WSH. I know this can be done by changing the registry but it will not take effect unless I reboot the machine. Please help.
0
malikatwork
Asked:
malikatwork
  • 2
1 Solution
 
fattumsdadCommented:
' Create the variables needed
Dim WSHShell
Dim WSHApp
Dim strRegKey
Dim strWallpaper
Dim strOSRoot
Dim strDesktop
Dim strDisplayProp

' Create the Wscript Shell object
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WSHApp   = CreateObject("Shell.Application")

' Define the wallpaper
strWallpaper   = "%SystemRoot%\Web\Wallpaper\PRWeb.html"
strDesktop     = WSHShell.SpecialFolders("Desktop")
strDisplayProp = "Display Properties"

' Create the wallpaper key
strRegKey =  "HKEY_CURRENT_USER\"
strRegKey = strRegKey & "Software\"
strRegKey = strRegKey & "Microsoft\"
strRegKey = strRegKey & "Internet Explorer\"
strRegKey = strRegKey & "Desktop\"
strRegKey = strRegKey & "General\"
strRegKey = strRegKey & "Wallpaper"

' Write the key, type, and value
WSHShell.RegWrite strRegKey, strWallpaper, "REG_EXPAND_SZ"

' Refresh the desktop now.
WSHApp.ControlPanelItem cstr("desk.cpl")
Do Until WSHShell.AppActivate (strDisplayProp)
Loop
WSHShell.SendKeys "{down}{up}{tab 3}a~"

From: http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20696851.html:
0
 
malikatworkAuthor Commented:
what if I want to set it to a jpeg on my hard drive  for example "c:\wallpaper.jpg"
This does not seem to be working...
0
 
malikatworkAuthor Commented:
ok I put the image in "%SystemRoot%\Web\Wallpaper\" folder and the background  changed but I get
an error :

rundll32.exe - Application error
"The instruction at "0x711d57f6" referenced memory at "0x66d21dd8". The memory could not be "read"
Click on OK to terminate the program
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now