Windows XP Random Logon Background (Wallpaper)¶
A script that sets a random logon background on every boot.
Background¶
The appearance of the logon screen is defined in the registry under HKEY_USERS.DEFAULT\Control Panel\Desktop
and HKEY_USERS.DEFAULT\Control Panel\Colors
(and maybe other places). The procedure described here modifies four keys, which set the path to the desired wallpaper, setup how the wallpaper is positioned and scaled and what the background colour should be.
The procedure involves Linux (or, more precisely, a bash shell) in order to create a .BAT
(batch) file for Windoze, which will setup the random image.
The wallpaper (background) images must be in .BMP
format.
Setup¶
Prepare a working directory¶
- Copy the background images into it (remember,
*.bmp
only!, avoid white space in the file names). - Copy the following two files into it, make the
.sh
script executable.
template.r-e-g: (adjust C:\GGLBG\
to suit your target directory on the windows machine).
Windows Registry Editor Version 5.00 [HKEY_USERS\.DEFAULT\Control Panel\Desktop] "TileWallpaper"="0" "Wallpaper"="C:\\GGLBG\\XXXXX" "WallpaperStyle"="0" [HKEY_USERS\.DEFAULT\Control Panel\Colors] "Background"="0 0 0"
makeregs.sh (again, adjust C:\GGLBG\
):
#!/bin/bash rm -f *.reg i=0 for X in *.bmp; do ((i=i+1)) n=`printf %05i $i` r="$n.reg" cp template.r-e-g $r sed -i "s/XXXXX/$X/" $r done echo "@echo off" > RANDIMG.BAT echo "set /a x=%random%*$i/32767+1" >> RANDIMG.BAT for ((j=1;j<=i;j++)); do echo "IF %x% == $j GOTO $j" >> RANDIMG.BAT done echo "GOTO end" >> RANDIMG.BAT for ((j=1;j<=i;j++)); do n=`printf %05i $j` echo ":$j" >> RANDIMG.BAT echo "regedit -s C:\\GGLBG\\${n}.reg" >> RANDIMG.BAT echo "GOTO end" >> RANDIMG.BAT done echo ":end" >> RANDIMG.BAT echo >> RANDIMG.BAT unix2dos RANDIMG.BAT echo "done." # eof
Run the script¶
makeregs.sh
will create a .reg
(registry) file for each .bmp
found in the directory. It will then create a batch file (RANDIMG.BAT
), which, when called, will setup one of the images as the logon wallpaper.
Copy the files to the windows machine¶
Copy the files in the working directory to the target directory on the windows machine (in this example: C:\GGLBG\
).
Setup windows to run the script at shutdown¶
Use the group policy editor (GPEDIT.MSC
) to setup a shutdown script (Computer configuration/Windows settings/Scripts). Add the RANDIMG.BAT
to the list.
Reboot¶
..and enjoy.