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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update windows background

Status
Not open for further replies.

dlingo

Programmer
Nov 19, 2001
60
0
0
US
I've written a script that successfully edits the user's background within Windows. I wrote the script using the RegWrite property to edit the HKEY_USERS registry value for Wallpaper.

The problem with the script is that it doesn't take affect until the next time the user logs onto Windows. It updates the registry successfully and these values are saved to the user's roaming profile upon Window's exit and the next time they log onto the domain the changes appear.

Is it possible to script this change to update the desktop immediately? If so, how would it be done?

Thanks in advance.
 
You need to broadcast a WM_SETTINGCHANGE message after making the change to the registry
 
strongm,

Thanks for your response. I used the following API functions to attempt the broadcast. I'm not including the Function declarations and the constant declarations.

SystemParametersInfo(SPI_SETDESKWALLPAPER, 0 , "C:\WINNT\winnt256.bmp", SPIF_SENDCHANGE)
BroadcastSystemMessage(BSFQUERY, BSM_ALLCOMPONENTS, WM_SETTINGCHANGE, SPI_SETDESKWALLPAPER, 0)

Both returned a one (non-negative), which is supposed to mean success, but no desktop update was done. Any additional help would be greatly appreciated.
 
Hello dlingo,
Code:
Public Const SPIF_UPDATEINIFILE = &H1
Public Const SPIF_SENDWININICHANGE = &H2

SystemParametersInfo SPI_SETDESKWALLPAPER, 0 , "C:\WINNT\winnt256.bmp", SPIF_UPDATEINIFILE or SPIF_SENDWININICHANGE
regards - tsuji


 
I've found a similar post elsewhere where someone is trying to get Windows to update based on changes to the registry made by VBS logon script. I also want to do something similar as described in thread329-731144 (no response yet) but like dlingo my computer does not reflect changes unless I reboot or restart which is not good enough. So far I still don't have an answer applicable in VBScript...


Suggestions were:

Microsoft describes how to perform a WM_SETTINGCHANGE but it is written in C. I for one don't know how which objects to create and format the commands in VBS.


Another person said to run this, but can I do this from within VBS?

RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

Another pointed to a Microsoft article saying fast logins (asynchronous) are the default unless the user has a user object logon script.


So far none of the ideas worked out. If we could get the WM_SETTINGCHANGE to run from a logon VBS script, then maybe that'll be the answer?

Confused? Well, so am I!
 
dbMark,

Seen your other thread before this. Just a quick remark here. If the line
Code:
   rundll32 user32.dll,UpdatePerUserSystemParameters
works on a start|run, it would certainly works in the vbs by shelling out .run or .exec.

Now, the problem is user32.dll version. If you look into user32.dll functions available to be called externally, you won't find it in win9x/ME. (This can be done by probing the dll with dependency walker.)

regards - tsuji
 
tsuji, does this update the whole registry or just HKCU ? I'm trying to update HKLM andthe line

rundll32 user32.dll,UpdatePerUserSystemParameters

doesn't seem to do the job.

TIA

 
Hello pmidds,

It does not guarantee to work. It is so much depending on the design of the application. Scripting in this regard can be unrewarding. Do not rely on it on critical task if you have alternative.

regards - tsuji
 
pmidds!!! hows it going? ;-)
have a look for strongm's approach.
i did something similar with an %logonserver% environment update recently you should find some example vb code on the H drive!! cant believe some guy has asked me to stop typing so loudly!!
 
rmovie :) I'll look at the WM_SETTINGCHANGE method but by the time i've worked it out it'll be quicker for me to package & distribute it either a) silently and will be picked up when user next reboots or b) normal package asking user to reboot - bit dramatic for a font update. Can't see where you've been shouting but I wouldn't be surprised ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top