Friday, January 9, 2009

HowTo: Rotate Desktop Wallpaper

Want your windows desktop background to change every time you login, but don't want to install a memory-hogging, computer-slowing program to do it?

1. Create a folder called wallpaper inside c:\ and put a bunch of bitmap (.bmp) images in it

2. Open up notepad, paste the code below into it, and save the file as C:\Documents and Settings\All Users\Start Menu\Programs\Startup\randwall.bat

Each time your computer starts up, it will pick a random picture from c:\wallpaper to use as your desktop background.

Notes: If you have more than 99 images, change the line "set R=!random:~-2!" to "set R=!random:~-3!" (for 999 images) or "set R=!random:~-4!" (for 9999 images). To use a directory other than c:\wallpaper, replace all instances of that path in the batch file with the new path.

PS Thanks go to Mechanix2Go at for the randomizer script

Here is the code for randwall.bat :



@echo off
setLocal EnableDelayedExpansion
for /f %%A in ('dir /b "C:\wallpaper\*.bmp"^|find /v /c "\"') do (set C=%%A)
:loop
(set R=!random:~-2!)
if !R! gtr !C! (goto :loop)
if !R! equ 0 (goto :loop)
for /f "tokens=*" %%A in ('dir /b "C:\wallpaper\*.bmp"') do (
(set /a N+=1)
if !N! equ !R! (
reg add "hkcu\control panel\desktop" /v wallpaper /t REG_SZ /d "" /f
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
reg add "hkcu\control panel\desktop" /v wallpaper /t REG_SZ /d "C:\wallpaper\%%A" /f
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
(goto :eof)
)
)

No comments: