Solved

WSH change wallpaper.

Posted on 2004-08-20
3
607 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mapAB Challlenge 35 89
Index Match Vlook up for a master file 7 49
Using VB6 to write Excel Spreadsheets - 5 20
Birthdays 3 22
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now