Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

setting windows wallpaper with a VBS script

969 views
Skip to first unread message

nk

unread,
Feb 6, 2004, 6:11:29 PM2/6/04
to
Hi guys,
Iam not an expert in VBscripting, and I am trying to set a wallpaper
and refresh it (without the user logoff) on winXP, win200 pro, and
win98 using the following script (coz of company marketing strategy).
Iam pushing this script via installshield to more than 1000 computers
with any of above os'.

The script seems to work fine on XP but doesnt work on win2k and
win98. The registries seem to be changing fine but the background
doesnot refresh with the rundll32 userdll call on the last line. Am I
missing anything ??
Please help!! Thanks,
NK

----------------------
----------------------
Dim WshShell, wpFile, wpStyle

set WshShell = CreateObject("Wscript.Shell")
'change this parameter for the destination wallpaper
wpFile = "%windir%\web\wallpaper\dt1.bmp"

'wallpaper style 2-stretch, 1-center;
wpStyle = 2

WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper",wpFile
WshShell.RegWrite "HKCU\Control Panel\Desktop\WallpaperStyle",wpStyle
WshShell.RegWrite "HKEY_USERS\.DEFAULT\Control
Panel\Desktop\Wallpaper",wpFile
WshShell.RegWrite "HKEY_USERS\.DEFAULT\Control
Panel\Desktop\WallpaperStyle",wpStyle

'WScript.Echo WshShell.RegRead("HKCU\Control Panel\Desktop\Wallpaper")
'msgbox (WshShell.RegRead("HKCU\Control
Panel\Desktop\WallpaperStyle"))

WshShell.Run _
"%windir%\System32\RUNDLL32.EXE
user32.dll,UpdatePerUserSystemParameters", _
1, False
----------------------
----------------------

Torgeir Bakken (MVP)

unread,
Feb 7, 2004, 8:34:42 AM2/7/04
to
nk wrote:

> Iam not an expert in VBscripting, and I am trying to set a wallpaper
> and refresh it (without the user logoff) on winXP, win200 pro, and
> win98 using the following script (coz of company marketing strategy).
> Iam pushing this script via installshield to more than 1000 computers
> with any of above os'.
>
> The script seems to work fine on XP but doesnt work on win2k and
> win98. The registries seem to be changing fine but the background
> doesnot refresh with the rundll32 userdll call on the last line. Am I
> missing anything ??

Hi

The rundll32 UpdatePerUserSystemParameters works for me on Win2k to refresh the
wallpaper, but as for Win98, it is not supported.

Try this free command line utility instead, it should work for all your OS
versions:

Set Wallpaper (SetWallpaper.exe)
http://www.optimumx.com/download/

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


nk

unread,
Feb 8, 2004, 12:54:07 PM2/8/04
to
"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message news:<4024E972...@hydro.com>...

> Hi
>
> The rundll32 UpdatePerUserSystemParameters works for me on Win2k to refresh the
> wallpaper, but as for Win98, it is not supported.
>
> Try this free command line utility instead, it should work for all your OS
> versions:
>
> Set Wallpaper (SetWallpaper.exe)
> http://www.optimumx.com/download/

Thanks for the tip. But is there a way to update / refresh via win32
api ? Any script or help available ? The script above seems more like
a hack than the actual way of achieving.
All help / thoughts are appreciated,
truly,
nk

mayayana

unread,
Feb 8, 2004, 9:23:53 PM2/8/04
to
> >
> > The rundll32 UpdatePerUserSystemParameters works for me on Win2k to
refresh the
> > wallpaper, but as for Win98, it is not supported.
> >
> > Try this free command line utility instead, it should work for all your
OS
> > versions:
> >
> > Set Wallpaper (SetWallpaper.exe)
> > http://www.optimumx.com/download/
>
> Thanks for the tip. But is there a way to update / refresh via win32
> api ? Any script or help available ? The script above seems more like
> a hack than the actual way of achieving.
> All help / thoughts are appreciated,

The system has to be informed of the change so that Explorer will
know to reload. There is an API method to do that but it can't be done
from script. A script cannot call API methods directly. If you want to use
a component see JSSys3.dll at
www.jsware.net/jsware/scripts.html

It might also work to use Sendkeys on the Display CPL after
doing the Registry settings, in order to update the change,
but I'm not sure.

0 new messages