---
title: "使用PS命令定时执行自动下载 Windows 10 聚焦壁纸"
url: https://www.landian.news/archives/52160.html
date: 2018-11-03T02:47:14+08:00
modified: 2018-11-02T18:47:14+00:00
author: "山外的鸭子哥"
description: "最近蓝点网的文章配图截图的各种壁纸似乎引起不少网友的兴趣，这些壁纸其实都是来自于微软必应搜索的。 也就是Win [&hellip;]"
categories: ""
tags: "PowerShell, windows, windows 10, 壁纸, 微软, 聚焦"
---

# 使用PS命令定时执行自动下载 Windows 10 聚焦壁纸

[!\[使用PS命令定时执行自动下载 Windows 10 聚焦壁纸\](https://dl.landian.news/?file=old/landian/media/images/Spotlight/fe22f9acd3313c5e21f8a78dc61a7875a42b489d2f3168336d360c050e85dee0.jpg)](https://dl.landian.news/?file=old/landian/media/images/Spotlight/fe22f9acd3313c5e21f8a78dc61a7875a42b489d2f3168336d360c050e85dee0.jpg)

最近蓝点网的文章配图截图的各种壁纸似乎引起不少网友的兴趣，这些壁纸其实都是来自于微软必应搜索的。

也就是Windows 10锁屏界面的壁纸保存后设置为桌面壁纸的，[蓝点网前面提到过如何保存聚焦更换的壁纸](https://www.landian.news/archives/51855.html)。

经网友提醒我们发现通过 Windows 10 Powershell 脚本也可以非常方便的下载壁纸并且自动进行转存等等。

所以用这种方式不需要安装其他应用还是非常方便的，脚本部分来自于中文博客 [PSTIPS](http://www.pstips.net/powershell-change-wallpaper.html) 网站在此表示感谢。

**另附最近几天的 Windows 10 聚焦壁纸下载：**[https://dl.landian.news/?dir=old/landian/media/images/Spotlight](https://dl.landian.news/?dir=old/landian/media/images/Spotlight)

**脚本自动转存聚焦壁纸：***（你也可以手动右键点击脚本选择Powershell执行）*

用记事本或代码编辑器新建文本文档然后粘贴以下内容，更改名称和后缀GetWallPaperFromSpotlight.ps1

懒得动手的话你也可以点击这里直接下载蓝点网做好的：[https://dl.landian.news/?dir=old/landian/Script/Spotlight/](https://dl.landian.news/?dir=old/landian/Script/Spotlight/)

执行后图片实际保存路径在：C:\Users\你的用户名\Pictures\Spotlight\Horizontal (不是Windows聚焦里)

```
# 将复制出来的缓存图片保存在下面的文件夹

add-type -AssemblyName System.Drawing
New-Item "$($env:USERPROFILE)\Pictures\Spotlight" -ItemType directory -Force;
New-Item "$($env:USERPROFILE)\Pictures\Spotlight\CopyAssets" -ItemType directory -Force;
New-Item "$($env:USERPROFILE)\Pictures\Spotlight\Horizontal" -ItemType directory -Force;
New-Item "$($env:USERPROFILE)\Pictures\Spotlight\Vertical" -ItemType directory -Force;

#路径说明：保存位置在你的用户名文件夹下的图片文件夹--->Spotlight--->Horizontal
 
# 将横竖图片分别复制到对应的两个文件夹

foreach($file in (Get-Item "$($env:LOCALAPPDATA)\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets\*"))
{
    if ((Get-Item $file).length -lt 100kb) { continue }
    Copy-Item $file.FullName "$($env:USERPROFILE)\Pictures\Spotlight\CopyAssets\$($file.Name).jpg";
}
 
foreach($newfile in (Get-Item "$($env:USERPROFILE)\Pictures\Spotlight\CopyAssets\*"))
{
    $image = New-Object -comObject WIA.ImageFile;
    $image.LoadFile($newfile.FullName);
    if($image.Width.ToString() -eq "1920"){ Move-Item $newfile.FullName "$($env:USERPROFILE)\Pictures\Spotlight\Horizontal" -Force; }
    elseif($image.Width.ToString() -eq "1080"){ Move-Item $newfile.FullName "$($env:USERPROFILE)\Pictures\Spotlight\Vertical" -Force; }
}
```

**将自动转存的聚焦图片设置为壁纸：可选**

前面的脚本只是自动转存Windows 10聚焦的壁纸但不会设置桌面壁纸，设置的话还是要你手动进行设置的。

当然也可以直接使用脚本自动转存然后自动进行设置，不过每个人喜好不同可能并不会喜欢所有推荐的壁纸。

所以这个是可选的如果你想保存还自动设置那就使用下面的脚本，不然就使用上面脚本再自己手动查看设置。

代码比较长这里不直接贴出来大家可以直接下载新脚本: [https://dl.landian.news/?dir=old/landian/Script/Spotlight/](https://dl.landian.news/?dir=old/landian/Script/Spotlight/)

文件说明：GetWallPaperFromSpotlight.ps1 只获取壁纸、SetWallPaperFromSpotlight.ps1 获取并设置。

**通过任务计划程序设定自动运行：**

1.首先解锁执行权限：微软小娜搜索框输入Powershell然后再右键点击搜索结果再选择使用管理员权限执行。

[!\[使用PS命令自动定时执行下载Windows 10聚焦壁纸\](https://img.lancdn.com/landian/2018/11/52160-1.avif)](https://img.lancdn.com/landian/2018/11/52160-1.avif)

2.打开管理员模式的Powershell 后输入 Set-ExecutionPolicy Unrestricted 按回车然后输入Y再按回车即可。

[!\[使用PS命令自动定时执行下载Windows 10聚焦壁纸\](https://img.lancdn.com/landian/2018/11/52160-2.avif)](https://img.lancdn.com/landian/2018/11/52160-2.avif)

3.接下微软小娜搜索框输入任务计划程序然后点击右侧的以管理员身份运行，打开后点击右侧创建基本任务。

[!\[使用PS命令自动定时执行下载Windows 10聚焦壁纸\](https://img.lancdn.com/landian/2018/11/52160-3.avif)](https://img.lancdn.com/landian/2018/11/52160-3.avif)

4.触发器可以按照自己的实际情况进行设置，蓝点网推荐大家直接设置计算机启动时即开机后自动执行脚本。

[!\[使用PS命令自动定时执行下载Windows 10聚焦壁纸\](https://img.lancdn.com/landian/2018/11/52160-4.avif)](https://img.lancdn.com/landian/2018/11/52160-4.avif)

5.这里选择启动程序然后点击浏览再选择下载好的.PS1脚本文件，请把脚本文件放到某个固定位置防止删除。

[!\[使用PS命令自动定时执行下载Windows 10聚焦壁纸\](https://img.lancdn.com/landian/2018/11/52160-5.avif)](https://img.lancdn.com/landian/2018/11/52160-5.avif)

[!\[使用PS命令自动定时执行下载Windows 10聚焦壁纸\](https://img.lancdn.com/landian/2018/11/52160-6.avif)](https://img.lancdn.com/landian/2018/11/52160-6.avif)

6.到这里基本设置完成所以点击结尾的完成即可，这里相当于是创建任务过程中的最终预览也可以再修改的。

[!\[使用PS命令自动定时执行下载Windows 10聚焦壁纸\](https://img.lancdn.com/landian/2018/11/52160-7.avif)](https://img.lancdn.com/landian/2018/11/52160-7.avif)

7.双击任务在常规下勾选不管用户是否登录都要运行及使用最高权限运行，确定会提示你输入账号密码确定。

[!\[使用PS命令自动定时执行下载Windows 10聚焦壁纸\](https://img.lancdn.com/landian/2018/11/52160-8.avif)](https://img.lancdn.com/landian/2018/11/52160-8.avif)

8.到这里就设置完成只要电脑开机包括重启系统都会自动执行脚本下载最新的聚焦壁纸并自动设置桌面壁纸。

正常情况下Windows 10 聚焦壁纸每天会换1张新的，所以设置完成后每天开机都会自动给你换成新的壁纸。

**最后的注意事项：**

此功能必须在Windows 10设置的个性化里---锁屏界面---背景里选择Windows聚焦否则无法获取新的壁纸。

另外使用管家卫士之类的用户不要使用自动优化，不然为了那可怜的0.几秒启动时间会把计划任务给禁用掉。

---

Source: [使用PS命令定时执行自动下载 Windows 10 聚焦壁纸](https://www.landian.news/archives/52160.html)
