Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting desktop background

Status
Not open for further replies.

Anubis3000

Programmer
Dec 20, 2004
52
US
Hi,

I am trying to set the desktop background using vbscript. I have tried everything in this thread:


This is my script file:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite"HKEY_USERS\.DEFAULT\Control Panel\Desktop\Wallpaper","C:\Documents and Settings\Desktop\New Folder\NULABWallpaper.JPG","REG_SZ"
WshShell.RegWrite"HKEY_USERS\.DEFAULT\Control Panel\Desktop\WallpaperStyle","0","REG_SZ"
WshShell.RegWrite"HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper","C:\Documents and Settings\Desktop\New Folder\NULABWallpaper.JPG","REG_SZ"
WshShell.RegWrite"HKEY_CURRENT_USER\Control Panel\Desktop\WallpaperStyle","0","REG_SZ"
wscript.echo "Wallpaper settings have been changed"


however, nothing works. When I go into the control panel and edit the display and then click on the desktop tab, the background is already changed to NULAB wallpaper, however, it is not displayed as wallpaper. I have administrator rights.

Please let me know if you have any advice. Thnx.
 
Looks to me like you have a bad path to the file:

C:\Documents and Settings\Desktop\New Folder\NULABWallpaper.JPG

I suggest that you put the file int he WIndows directory or make it accessible from the network and use a UNC path.

I hope you find this post helpful.

Regards,

Mark
 
might be off topic as i havent had any coffee yet, but is this the type of setting which requires a reboot? or more precisely does it require informing windows that something in the registry has changed and it should refresh?? something like SendMessage API calls or is it WMBroadcast...
 
Would not require a reboot. MAY require a logoff, but using as a login script will ensure the settig remains perpetual after the first login.

I hope you find this post helpful.

Regards,

Mark
 
For right now, I am keeping the desktop background on my local machine so as to test the script.

When I reboot my cpu, I do not have any background (I have the cpu set to one background, and then this script changes it to another; when I startup, I do not see any background at all)

I am thinking that your idea about informing windows that there has been a change in the registry might be correct, however, I do not know the syntax.


 
a reboot is the easy way out so to speak
i think mark is prob right with the fact a log off and on again will be enough.

however, it sounds like after a reboot your machine has not done what you intended it to.

i dont have anything ready made to do what you want, other than trying the previous posts i tend to find generally with these sorts of registry things it is best to clear the air by snapping the registry (somthing like regsnap) before you make your changes, make you changes via the gui then compare the differences and put these differences into your script.

if you are sure you know where the registry settings are then use regeidt to make sure all your changes are as you expected from your script, if they are 'correct' but windows isnt doing what you want then you must have the registry changes wrong, i hope i am making sense.

with regards to reboots, log offs, informing windows things have changed etc i tend to work as follows:

1. get the thing working via script (dont worry if a reboot etc is required

second to that you can than start to worry about how you are going to implement it, with or without reboots etc or work around the issue and have you implementation handle it,,,an example of this is the logonscript suggestion
 
sorry, have you had a look at marks suggestion about the path in the registry to the file in question?
try what mark suggests, or even simpler just chuck it in C:\ and see if you can get that working
 
Are you looking to have this show up as the default background and not a user background? Sounds to me like your trying to see something you are not setting based on the code you posted.

From your last post I think that what you are looking for is set in

HKEY_USERS\.DEFAULT\Control Panel\Desktop\Wallpaper

You have been setting the Current User, though my original observation seems to still be accurate that the file is not in the right place per your posted info.

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top