New
#210
Hi @Ginosergio and welcome to Tenforums!
To create your "Custom-made Spotlight", which will be changing LockScreen images from a predefined images folder, run this PowerShell script, from an elevated PowerShell console:
Upon execution, the script will create a new Registry key, to take over the LockScreen image changing function of the system.Code:#Requires -RunAsAdministrator function Get-RandomNumber { $RandomBytes = New-Object -TypeName "System.Byte[]" 4 $Random = New-Object -TypeName "System.Security.Cryptography.RNGCryptoServiceProvider" $Random.GetBytes($RandomBytes) [BitConverter]::ToInt32($RandomBytes, 0) } $RegistryKey = "Registry::\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP" $ImagesFolder = "$env:USERPROFILE\Pictures\Wallpapers" $LockScreenImageValue = (Get-ChildItem -Path $ImagesFolder | Get-Random -SetSeed (Get-RandomNumber) -Count 1).FullName if (!(Test-Path $RegistryKey)) { New-Item -Path $RegistryKey -Force | Out-Null } # Create/Modify Registry entries for Lock Screen Set-ItemProperty -Path $RegistryKey -Name "LockScreenImageStatus" -Type DWord -Value 1 -Force Set-ItemProperty -Path $RegistryKey -Name "LockScreenImagePath" -Type String -Value $LockScreenImageValue -Force Set-ItemProperty -Path $RegistryKey -Name "LockScreenImageUrl" -Type String -Value $LockScreenImageValue -Force #Ensure the changes to the Lock screen image take place immediately rundll32.exe user32.dll, UpdatePerUserSystemParameters
Every time it runs, it randomly selects one of the images in the specified images folder and sets it as your LockScreen image.
It can be run on demand, but it works better if you schedule it to run, let's say daily and it will change the LockScreen image, the way Windows Spotlight is supposed to (whenever it works!!!)
The file you save the script in, must have an extension .ps1
It can be put in any convenient to you folder, as long as you reference it with its complete path (e.g. D:\Pictures\MyWallpapers\Set-LockScreen.ps1)
In the script change the $ImagesFolder = "$env:USERPROFILE\Pictures\Wallpapers" to the folder your images will be. If you keep your images in "D:\Pictures\MyWallpapers", make it$ImagesFolder = "D:\Pictures\MyWallpapers"
.
Just FYI, the $env:USERPROFILE prefix I have put in the script, is a PowerShell variable, for the folder C:\Users\<UserName>, but since the <UserName> is different for every user, PowerShell provides this so you can make the script generic i.e. to be used by anyone without knowing the UserName.
For convenience you can download and use the following script, in which I took the liberty (according to your post) to make the images folder D:\Pictures\MyWallpapers.
If that's the case you can use it as is: Set-LockScreen.ps1
Now let’s go to the task, you need to create for our "Custom-made SpotLight":
The task you create needs to open PowerShell and run the script. To do that just follow the screenshots below:
In Task Scheduler select “Create Task”.
In General tab give a name to your task and make sure you check “Run with highest privileges”.
Then in the Triggers tab, click on Edit
and schedule when the task will be running.
In the Actions tab create a new Action to “Start a program” and in the “Program/script” field type (or Copy/Paste from here) the following:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
In the “Add arguments (optional)” field type (or Copy/Paste from here) the following:
-WindowStyle Hidden -NonInteractive -ExecutionPolicy Bypass -File "D:\Pictures\MyWallpapers\Set-LockScreen.ps1"
provided that you put the script in the D:\Pictures\MyWallpapers folder, otherwise change it to the folder your Set-LockScreen.ps1 file resides.
In the Conditions tab, if you wish you can check “Wake the computer to run this task”.
In the Settings tab, make sure you check “Allow task to be run on demand” (for testing purposes) and the other options either leave them as shown in the picture or change according to your needs.
Click OK and the task is done.
Finally, there is nothing you do in Settings, to set this “Custom-made SpotLight”.
Once you run the script, if you go to Settings > Personalization > Lock screen, you will see that you can’t change anything, since the Registry key the script adds, disables any selection.
That is the last comment I made in my previous post. That if you want to bring back everything to what it was, before the script run, you have to go in the Registry and delete the keyHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP
Then everything will be again selectable as it was before, but you will not have your "Custom-made Spotlight"!
I hope to have helped.
Good luck with it and if you find any problem, do not hesitate to post back.
Cheers. Dimitri
Last edited by ddelo; 20 Feb 2021 at 00:58.