63
63

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 5 years have passed since last update.

Windowsの環境変数をPowerShellで書き変える

Last updated at Posted at 2013-12-15

Windows環境変数を書き変えることが多く、いちいちシステムの詳細設定を開くのがめんどくさい人向け。

  • ユーザーの環境変数
> [System.Environment]::SetEnvironmentVariable('M2_REPO', 'C:\Users\mmorita\.m2\repository',[System.EnvironmentVariableTarget]::User)
または
> [Environment]::SetEnvironmentVariable('M2_REPO', 'C:\Users\mmorita\.m2\repository', 'User')
  • システムの環境変数
> [System.Environment]::SetEnvironmentVariable('M2_REPO', 'C:\Users\mmorita\.m2\repository',[System.EnvironmentVariableTarget]::Machine)
または
> [Environment]::SetEnvironmentVariable('M2_REPO', 'C:\Users\mmorita\.m2\repository', 'Machine')

PATHの追加とかもできます。

> $path = [Environment]::GetEnvironmentVariable('PATH', 'Machine')
> $path += ';' + 'C:\tools\apache\maven\bin'
> [Environment]::SetEnvironmentVariable('PATH', $path, 'Machine')

APIの説明は↓とか参照。

http://msdn.microsoft.com/ja-jp/library/96xafkes(v=vs.110).aspx

なお、設定しても、既に起動しているプロセスには効かないので、プロセスを起動し直すなどの対応が必要です。

63
63
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
63
63

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?