Windows Lock Screen custom picture not working


QuicktellPro

Member
Local time
10:16 PM
Posts
21
OS
Windows 11
Hi,
I'm running 24H2 and have changed the lock screen image to one of my photos having the same dimensions. If I type the Windows key and L, the photo is shown correctly, however, when I start the PC, the lock screen is always the default blue folding image. I know it's not really important, but is there a workaround I can use to make the lock screen always show my photo, please?

lockscreen_settings.webp
 
Windows Build/Version
24H2

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Alienware A51 R2
    CPU
    Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
    Memory
    32,0 GB
    Graphics Card(s)
    Nvidia GeForce RTX2080 Super
    Sound Card
    Realtek
    Screen Resolution
    4K
My impression is Settings will sometimes forget to update all the necessary reg values.

So I wrote a batch script to force it to work.
Code:
LockScreen.bat \path\to\image.jpg
 

Attachments

My Computer

System One

  • OS
    Windows 7
Thank you very much, that fixed it!
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Alienware A51 R2
    CPU
    Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
    Memory
    32,0 GB
    Graphics Card(s)
    Nvidia GeForce RTX2080 Super
    Sound Card
    Realtek
    Screen Resolution
    4K
Incidentally, the only reason I changed my lock screen picture was because Windows spotlight does not work. I tried that setting numerous times but Windows always changed it back to picture.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Alienware A51 R2
    CPU
    Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
    Memory
    32,0 GB
    Graphics Card(s)
    Nvidia GeForce RTX2080 Super
    Sound Card
    Realtek
    Screen Resolution
    4K
My impression is Settings will sometimes forget to update all the necessary reg values.

So I wrote a batch script to force it to work.
Code:
LockScreen.bat \path\to\image.jpg
It's doing it again. Perhaps I didn't use your batch script correctly.
I ignored the line of code you provided because I did not know what it meant. Instead, I opened the script with Notepad and changed the 2 items I felt were relevant being USERNAME and image.jpg. After saving it with a .bat extension, I ran it as administrator. Could you check it for me please Garlin, and if I have gone wrong, let me know what needs changing.
 

Attachments

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Alienware A51 R2
    CPU
    Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
    Memory
    32,0 GB
    Graphics Card(s)
    Nvidia GeForce RTX2080 Super
    Sound Card
    Realtek
    Screen Resolution
    4K
This should be a full pathname with file extension.
Code:
if ($args[0] -eq '') {
    $Filename = 'C:\Windows\Web\Screen\img134d.jpg'
}

I don't understand this change. What is user profile environment variable "AE"?
Code:
$SID = (Get-LocalUser -Name $env:ae).SID

The script has to lookup your account name, in order to find your SID. The reg values are written for each user, based on their unique SID.
 

My Computer

System One

  • OS
    Windows 7
This should be a full pathname with file extension.
Code:
if ($args[0] -eq '') {
    $Filename = 'C:\Windows\Web\Screen\img134d.jpg'
}

I don't understand this change. What is user profile environment variable "AE"?
Code:
$SID = (Get-LocalUser -Name $env:ae).SID

The script has to lookup your account name, in order to find your SID. The reg values are written for each user, based on their unique SID.
I have modified it again according to your comments. Can you check it for me please.

Also, what did you mean by this: LockScreen.bat \path\to\image.jpg

Is that something I have to run from the terminal?
 

Attachments

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Alienware A51 R2
    CPU
    Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
    Memory
    32,0 GB
    Graphics Card(s)
    Nvidia GeForce RTX2080 Super
    Sound Card
    Realtek
    Screen Resolution
    4K
I have modified it again according to your comments. Can you check it for me please.

Also, what did you mean by this: LockScreen.bat \path\to\image.jpg

Is that something I have to run from the terminal?
You have to run the script from a Terminal session.

My script makes no assumptions about your current reg values (maybe they're broken?). So it forces all of the settings at the same time. If you edited the script to allow for no command-line arguments, then the image filename is now optional.
 

My Computer

System One

  • OS
    Windows 7
If you edited the script to allow for no command-line arguments, then the image filename is now optional.
Sorry, but I do not understand what you meant by that. I am only an intermediate user and know almost nothing about command-line operations. The only change I made to your script was the precise location of the image file I want to use. I reverted the 'ae' change back to 'USERNAME' following your previous post.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Alienware A51 R2
    CPU
    Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
    Memory
    32,0 GB
    Graphics Card(s)
    Nvidia GeForce RTX2080 Super
    Sound Card
    Realtek
    Screen Resolution
    4K
If you don't like having a command-line option to pick the image, then you can force the same image filename inside the script. Now you don't have to do anything but to run the script by hand, or double-click it from Explorer.

Code:
<# : batch script
@echo off
powershell -nop ^
"if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) { ^
    Start-Process 'cmd' -ArgumentList '/c start /min %~dpnx0' -Verb RunAs ^
} ^
else { ^
    Invoke-Expression ([System.IO.File]::ReadAllText('%~f0')) ^
}"
goto :eof
#>

$Filename = 'C:\Windows\Web\Screen\img134d.jpg'

if ((Get-Item $Filename -ErrorAction SilentlyContinue) -eq $null) {
    "ERROR: $Filename not found."
    exit 1
}

$FullName = (Get-Item $Filename).FullName

$SID = (Get-LocalUser -Name $env:USERNAME).SID

$Path = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
Set-ItemProperty -Path $Path -Name 'RotatingLockScreenEnabled' -Value 0 -Force
Set-ItemProperty -Path $Path -Name 'RotatingLockScreenOverlayEnabled' -Value 0 -Force
Set-ItemProperty -Path $Path -Name 'SubscribedContent-338387Enabled' -Value 0 -Force

$Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Creative\$SID"
$null = New-Item -Path $Path -Force
$null = New-ItemProperty -Path $Path -Name 'RotatingLockScreenEnabled' -Value 0 -Force
$null = New-ItemProperty -Path $Path -Name 'RotatingLockScreenOverlayEnabled' -Value 0 -Force

$Path = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP'
$null = New-Item -Path $Path -Force
Set-ItemProperty -Path $Path -Name 'LockScreenImageStatus' -Value 1 -Force
Set-ItemProperty -Path $Path -Name 'LockScreenImagePath' -Value $FullName -Force
Set-ItemProperty -Path $Path -Name 'LockScreenImageUrl' -Value $FullName -Force

$Path = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization'
$null = New-Item -Path $Path -Force
Set-ItemProperty -Path $Path -Name 'NoLockScreen' -Value 0 -Force
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\System' -Name 'DisableLogonBackgroundImage' -Value 0 -Force
 

My Computer

System One

  • OS
    Windows 7
Isn't that the same as the modified script I last sent you?
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Alienware A51 R2
    CPU
    Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
    Memory
    32,0 GB
    Graphics Card(s)
    Nvidia GeForce RTX2080 Super
    Sound Card
    Realtek
    Screen Resolution
    4K
No, because I removed all the argument passing and checking. 4 lines have changed.
Ok, thanks for that. I will run it again.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Alienware A51 R2
    CPU
    Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
    Memory
    32,0 GB
    Graphics Card(s)
    Nvidia GeForce RTX2080 Super
    Sound Card
    Realtek
    Screen Resolution
    4K
Back
Top Bottom