LoginSignup
21
24

More than 5 years have passed since last update.

「windows」で「PowerShell」を「一切画面表示せず」に「タスクスケジューラに登録」する方法を再確認

Posted at

何も考えずにタスクスケジューラでpowerShellを登録すると、一瞬ウィンドウが表示されるダサい事になっちゃうんだよね。-windowstyle hidden を付けても意味なし。

意味が無い
ダメな例。

じゃあどうするんかってーと、powershell.exeを使う限りどうしようもないので他の言語に頼る事になるってのが常套手段。このブログとか。
PowerShellの盲点 バイクと癒しのおじさんブログ/ウェブリブログ

具体的に以下のjsファイルを作る

task-scheduler.js
wsShell = WScript.createObject("WScript.Shell");
retCode = wsShell.Run("\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -File \"" + WScript.Arguments.Item(0)+"\"",0,true);
WScript.Quit(retCode);

タスクスケジューラにはこう登録する。カレントディレクトリもちゃんと反映される。
imgTemp-2016-05-01-10-36-18.png

これでオッケー と。

21
24
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
21
24