Solved

WSH change wallpaper.

Posted on 2004-08-20
3
616 Views
Last Modified: 2012-05-05
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
Comment
Question by:malikatwork
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
fattumsdad earned 150 total points
ID: 11853789
' 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
 

Author Comment

by:malikatwork
ID: 11853938
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
 

Author Comment

by:malikatwork
ID: 11854124
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question