我有一个网络摄像头,每15分钟上传一张新照片。php脚本确保最新的照片显示在url(example.com/webcam)
[图像文件名格式基于拍摄时间(例如:20200115113433.jpg)
我正在寻找一个可以在后台运行的简单powershell脚本,将最新图像下载到本地文件夹并将其设置为墙纸。
附加功能:
仅在可以连接互联网并有新文件的情况下下载并设置墙纸。
如果满足条件,请每30分钟下载图像并更换墙纸
任何帮助表示感谢
计划任务是最好的方法吗?很抱歉出现菜鸟问题。我是这个论坛和PowerShell的新手。
$URL = "http://www.example.com/webcam/"
$Destination = "C:\Webcam"
#Get image from site
$Site = iwr -Uri $URL
$Images = ($Site).Images.src
foreach ($Image in $Images) {
Start-BitsTransfer -Source $Image -Destination $Destination -TransferType Download
}
#Get filename and define full path
$Filename = Split-Path $image -leaf
$Fullpath = join-path -path $Destination -childpath $Filename
#Change wallpaper
Function Set-WallPaper($Value)
{
Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $value
rundll32.exe user32.dll, UpdatePerUserSystemParameters
rundll32.exe user32.dll, UpdatePerUserSystemParameters
rundll32.exe user32.dll, UpdatePerUserSystemParameters
}
Set-WallPaper -value $Fullpath