LoginSignup
6

More than 5 years have passed since last update.

Powershellでスクリプトファイル.ps1の位置を実行ディレクトリにする

Posted at

いっつも忘れるのでメモ。

Set-Location (Split-Path $MyInvocation.MyCommand.Path -parent)

やってることは簡単で、 $MyInvocation.MyCommand.Path でスクリプトファイルのパスを取得して、 Split-Path でパスを分解、 -parent で親パス(つまりディレクトリ)を取得して、そのパスを Set-Location で実行ディレクトリにする、です。

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
6