タスクスケジューラーとシェルスクリプトで実現可能。
Add-Type @"
using System.Runtime.InteropServices;
public class Wallpaper {
[DllImport("user32.dll", SetLastError=true)]
public static extern bool SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
}
"@
$wallpaper1 = "C:\WallpaperSchedule\wallpaper1.jpg"
$wallpaper2 = "C:\WallpaperSchedule\wallpaper2.jpg"
$now = Get-Date
$isThursday = ($now.DayOfWeek -eq "Thursday")
$hour = $now.Hour
if ($isThursday -and $hour -ge 16 -and $hour -lt 19) {
$path = $wallpaper1
} else {
$path = $wallpaper2
}
if (Test-Path $path) {
[Wallpaper]::SystemParametersInfo(20, 0, $path, 3)
}壁紙のファイルは
C:\WallpaperSchedule\wallpaper1.jpg
C:\WallpaperSchedule\wallpaper2.jpg
のようにおいておく。
タスクスケジューラーで、ログオン時に C:\WallpaperSchedule\set-wallpaper.ps1 を実行するようにする。
全般 タブ
- 名前:
曜日で壁紙変更 ユーザーがログオンしているときのみ実行するを選ぶ
トリガー タブ
新規タスクの開始:ログオン時- 必要なら
特定のユーザーを自分にする OK
操作 タブ
新規操作:プログラムの開始プログラム/スクリプト:powershell.exe引数の追加:-ExecutionPolicy Bypass -File "C:\WallpaperSchedule\set-wallpaper.ps1"
条件 タブ
- (任意)
AC電源でのみ開始のチェックを外す
設定 タブ
要求時にタスクを実行するにチェック