0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

タスクスケジューラでCLIコマンド実行時にウィンドウを非表示にする

Posted at

WindowsのタスクスケジューラからCLIコマンドを実行すると、
デフォルトでターミナルウィンドウが表示されます。
これを非表示にする設定が下記です。

conhost.exe powershell -WindowStyle Hidden -Command "CLIコマンド"

備考

タスクスケジューラの画面に合わせて分解すると以下。

  • プログラム/スクリプト: conhost.exe
  • 引数の追加: powershell -WindowStyle Hidden -Command "コマンド"

各要素について、

  • conhost.exeは旧DOS窓。単体で起動したら確認できます。
  • -WindowStyle Hiddenはウィンドウを非表示にするオプション。
    しかし、最新のウィンドウズターミナルには効きません。旧DOS窓には効きます。
  • powershell.exeに付随して表示されるのはウィンドウズターミナル。
    よって、-WindowStyle Hiddenは効きません。
  • 結果、conhost.exe powershell -WindowStyle Hidden ~という書き方にすることで
    旧DOS窓上でpowershellを実行、-WindowStyle Hiddenの効果も発動という動作になります。
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?