如何选择合适的建站公司,爱网站免费一站二站,商品分类批量导入wordpress,页游网站建设目录 一. 相关网址二. 壁纸随机更换思路三. 指定 WindowsTermina 壁纸路径四. 编写脚本#xff0c;随机替换壁纸4.1 powershell脚本4.2 .bat批处理脚本 四. 配置定时任务#xff0c;添加触发器五. 效果 一. 相关网址
官方下载 Windows Terminal 官方Github微软商店 美化 Oh … 目录 一. 相关网址二. 壁纸随机更换思路三. 指定 WindowsTermina 壁纸路径四. 编写脚本随机替换壁纸4.1 powershell脚本4.2 .bat批处理脚本 四. 配置定时任务添加触发器五. 效果 一. 相关网址
官方下载 Windows Terminal 官方Github微软商店 美化 Oh My Poshwindowsterminalthemes微软官方Windows终端设置教程 二. 壁纸随机更换思路
WindowsTerminal的壁纸在其settings.json文件中可自定义指定编写脚本读取指定文件夹下的所有壁纸文件随机获取一张壁纸将壁纸复制到settings.json中指定的路径下若有既存的文件强制覆盖配置定时任务设置触发器在用户启动电脑的时候触发脚本执行 三. 指定 WindowsTermina 壁纸路径
⏹如下图所示指定壁纸的路径和透明度 四. 编写脚本随机替换壁纸
⏹文件夹详情 4.1 powershell脚本
⏹change_background_image.ps1
# 父文件夹
$Paretn_Path F:\99-Windows_Terminal\
# 壁纸文件夹
$Wallpaper_BK_Path $($Paretn_Path)\02-Wallpaper_BK\
# Windows_Terminal所需壁纸文件路径
$Wallpaper_Path $($Paretn_Path)\01-Wallpaper\img.jpg# 递归获取所有的壁纸的绝对路径
$Wallpaper_list Get-ChildItem -Path $Wallpaper_BK_Path -Recurse -File
| ForEach-Object { $_.FullName }# 从所有的壁纸中随机获取一张壁纸下标
$Random_Wallpaper_Index Get-Random -Minimum 0 -Maximum (($Wallpaper_list | Measure-Object).Count - 1)
# 获取要移动的壁纸对象
$Random_Wallpaper_Full_Path $Wallpaper_list[$Random_Wallpaper_Index]# 复制壁纸路径到指定指定文件夹中如果有同名文件直接强制覆盖
Copy-Item -Path $Random_Wallpaper_Full_Path -Destination $Wallpaper_Path -Force4.2 .bat批处理脚本
⏹change_background_image.bat
部分电脑可能禁用PowerShell代码因此提供.bat批处理脚本由于批处理的代码晦涩难懂此处将批处理代码与PowerShell代码相结合在批处理中文件中调用批处理文件中内含PowerShell代码
(echo NUL
echo off)setlocal ENABLEDELAYEDEXPANSIONset ARGV0%~f0
set ARGS%*
set ARGC0for %%V in (%*) do (set /a ARGC!ARGC!1set ARGV!ARGC!%%V
)PowerShell.exe -Command Invoke-Expression -Command ((Get-Content \%ARGV0: %\) -join \n\)
exit /b %errorlevel%
) | Out-Null# -------------------以下为PowerShell代码部分-------------------$argc$ENV:ARGC
$argv()
for($i0;$i -le $argc;$i){$argv (Get-ChildItem ENV:ARGV$i).Value
}# -------------------PowerShell代码处理的主体部分-------------------# 父文件夹
$Paretn_Path F:\99-Windows_Terminal\
# 壁纸文件夹
$Wallpaper_BK_Path $($Paretn_Path)\02-Wallpaper_BK\
# Windows_Terminal所需壁纸文件路径
$Wallpaper_Path $($Paretn_Path)\01-Wallpaper\img.jpg# 递归获取所有的壁纸的绝对路径
$Wallpaper_list Get-ChildItem -Path $Wallpaper_BK_Path -Recurse -File
| ForEach-Object { $_.FullName }# 从所有的壁纸中随机获取一张壁纸下标
$Random_Wallpaper_Index Get-Random -Minimum 0 -Maximum (($Wallpaper_list | Measure-Object).Count - 1)
# 获取要移动的壁纸对象
$Random_Wallpaper_Full_Path $Wallpaper_list[$Random_Wallpaper_Index]# 复制壁纸路径到指定指定文件夹中如果有同名文件直接强制覆盖
Copy-Item -Path $Random_Wallpaper_Full_Path -Destination $Wallpaper_Path -Force四. 配置定时任务添加触发器
⏹任务计划程序
快捷键Win R打开运行窗口在运行窗口内输入taskschd.msc打开任务计划程序
⏹在操作选项卡中点击创建基本任务打开任务创建向导。 ⏹当我们使用powerhell脚本时需要指定通过powershell.exe来运行还需要配置脚本的参数指定脚本路径 ⏹由于是开机启动的脚本还需要配置完成之后在属性选项卡中进行如下配置。 五. 效果
⏹按照上述配置之后每次开机或重启之后WindowsTerminal的壁纸就会更换。 也可根据需求选择工作站锁定时或工作站解锁时触发脚本执行。