[英]How to set lock screen photo using PowerShell?
如何將鎖定屏幕從“Windows 聚光燈”設置為“照片”,然后將照片設置為特定圖像。
這是我嘗試過的:
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization' -Name LockScreenImage -value "C:\Custom-Folder\wallpaper.jpg"
它給了我一個錯誤,並說路徑不存在。
這是錯誤消息:
Set-ItemProperty : Cannot find path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization' because it
does not exist.
At line:1 char:1
+ Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Per ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKLM:\SOFTWARE\...Personalization:String) [Set-ItemProperty], I
temNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetItemPropertyCommand
您需要確保注冊表項存在,否則首先創建它。
你可以很容易地做到這一點
$regKey = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization'
# either create the new key or return an object of the existing key
# in both cases we don't need that object any further so we ignore with $null = ..
$null = New-Item -Path $regKey -Force
# now set the registry entry
Set-ItemProperty -Path $regKey -Name LockScreenImage -value "C:\Custom-Folder\wallpaper.jpg"
因為這是在HKEY_LOCAL_MACHINE
您需要以管理員身份運行此代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.