0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

バッチファイルで指定時間まで待つ

Last updated at Posted at 2020-10-29

バッチファイルで PowerShell を使って指定時間まで待つ。
指定時間が過ぎていたら、次の日の指定時間まで待つ。
スケジューラ登録するほどでもない、管理者権限がない ときに。
(Windows10, Window7 等)

daily.bat

@echo off
echo 22時59分まで待ちます。

powershell "if ((get-date) -lt (get-date -hour 22 -minute 59 -second 0)) { $w = get-date -hour 22 -minute 59 -second 0 } else { $w = (get-date -hour 22 -minute 59 -second 0).adddays(1)} ; $w = new-timespan -start (get-date) -end $w ; Start-Sleep -seconds $w.totalseconds ; $ws = New-Object -com Wscript.Shell"

rem バックアップ処理 robocopy , bunbackup 等

rem 自分自身を再実行
start /min %~dpnx0

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?