Windows 7 Log-on Background

Logon, login, I don’t know.

I decided to change my login screen background, which was easy enough.

Enable it in the registry:

I like the idea of it changing occasionally, without me having to do anything special.

Whilst I’m more than capable of writing an actual application to do this, I like batch files because they don’t require invoking an entire runtime, or recompiling for little edits.

The batch file doesn’t scan for images because they honestly won’t change often enough to be worth the associated cost, and to save keeping a list I’ve just numbered them.
In this case 1.jpg, 2.jpg, .. 16.jpg

They all match the 1280×1024 resolution of my display, have a size of less than 256KB and are stored in
C:\Windows\System32\oobe\info\backgrounds\
along with the following batch file:

First off, it reads in the current.txt file, which consists of a number and a new line.
This number is used to set the ‘current’ variable.

Then a random number is generated and squished down to be between 1 and 16 (for I have 16 images).

If the number happens to equal the current background then the script loops back and tries again.
So running with one image and set /a rand=(rand*1/32768)+1 would be.. infinite.

Once there is a new image ID selected, the file is copied and overwrites the current one – this saves keeping track of names and the risk of leaving no replacement file.

The ID of this new one is stored in current.txt, and to avoid extra spaces is written %rand%>current.txt
This gives issues when the number infront of the > is recognised, such as 2> (or anything below 10). So we need to escape it with the ^ symbol.

Obviously at this stage, I still need to run it manually – so, Task Scheduler:

Add a new task, which runs with the highest privileges, triggers at log on and executes that batch file with a ‘start in’ of C:\Windows\System32\oobe\info\backgrounds

If you have UAC enabled.. you’re gonna have to sod around with the security tab a bit (or just move files using cmd.exe as admin) and run things as admin – doesn’t take long.

Probably a huge security hole having a user writable auto executing batch file in a system directory so it’s all at your own risk.

Leave a Reply