答案1
如果您想通过注册表执行此操作。这是一个糟糕的想法,注册表黑客始终是最后的手段,因为它很容易被破坏。我只能说祝你好运;你想要的密钥是HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lock Screen
,但格式完全不透明,而且这还不是全部:实际的锁定图像存储在文件夹中C:\ProgramData\Microsoft\Windows\SystemData\{SID}\ReadOnly\LockScreen_B
,该文件夹通常仅供系统使用。
解决方法如下:
需要 ps 脚本和 regedit
我通过登录脚本(bat 文件)进行部署
这是 ps 脚本- 这将为登录用户进行所有设置并更改锁定屏幕:
# Change this to the path where you keep the desired background image
$imagePath = '(Path to Image, include single quotes)'
$newImagePath = [System.IO.Path]::GetDirectoryName($imagePath) + '\' + (New-Guid).Guid + [System.IO.Path]::GetExtension($imagePath)
Copy-Item $imagePath $newImagePath
[Windows.System.UserProfile.LockScreen,Windows.System.UserProfile,ContentType=WindowsRuntime] | Out-Null
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
Function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
$netTask.Result
}
Function AwaitAction($WinRtAction) {
$asTask = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and !$_.IsGenericMethod })[0]
$netTask = $asTask.Invoke($null, @($WinRtAction))
$netTask.Wait(-1) | Out-Null
}
[Windows.Storage.StorageFile,Windows.Storage,ContentType=WindowsRuntime] | Out-Null
$image = Await ([Windows.Storage.StorageFile]::GetFileFromPathAsync($newImagePath)) ([Windows.Storage.StorageFile])
AwaitAction ([Windows.System.UserProfile.LockScreen]::SetImageFileAsync($image))
Remove-Item $newImagePath
这是更改登录屏幕的注册表
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Creative\S-1-0-0]
"RotatingLockScreenEnabled"=dword:00000000
"LockImageFlags"=dword:00000000
"LockScreenOptions"=dword:00000000
"CreativeId"=""
"PortraitAssetPath"="(Path to Image, include double quotes, remember to use \\ in between folders)"
"LandscapeAssetPath"="(Path to Image, include double quotes, remember to use \\ in between folders)"
这是登录 bat 文件
CLS
@echo off
regedit /S (insert path to .reg file here)
IF NOT EXIST (Local Path storing image) (
mkdir (Local Path storing image)
xcopy (From path) (Local Path storing image) /R /Y /I
) ELSE ECHO Applying Lock Screen
Powershell.exe -executionpolicy remotesigned -File (Path to ps1 file)
Exit
EXIT
答案2
重置锁屏图片缓存,以便可以设置图片
尝试这些操作之前请先备份计算机。
打开 Regedit,转到(如果存在,可能不适用):
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lock Screen\Creative
将所有标志设置为将所有“LockImageFlags”设置为0
,测试(再次设置图像)。
- 得;
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lock Screen\
FirstLockAfterOSInstall
删除除; 、、、、、之外LockAppAumId
的 所有条目,然后测试(再次设置图像)。SlideshowDirectoryPath1
SlideshowEnabled
SlideshowSourceDirectoriesSet
TileMigrated
(ignore settings in lower picture)
- 如果这些都不起作用,则如果适用,请再次运行上述两个操作,然后以管理员身份制作并运行此脚本(以清除锁屏用户缓存);
清除锁屏缓存.bat
call takeown /f C:\ProgramData\Microsoft\Windows\SystemData /R /D Y
call icacls C:\ProgramData\Microsoft\Windows\SystemData /grant "%USERDOMAIN%\%USERNAME%":(F) /T /C
call Del /s /q C:\ProgramData\Microsoft\Windows\SystemData\*.*
call icacls C:\ProgramData\Microsoft\Windows\SystemData /reset /T /C
call exit
再次设置图像,现在应该可以工作了。