-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
24 lines (18 loc) · 863 Bytes
/
setup.ps1
File metadata and controls
24 lines (18 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# カレントディレクトリを取得
$currentDir = Get-Location
# scripts ディレクトリのパスを作成
$scriptsDir = Join-Path -Path $currentDir -ChildPath "scripts"
# 現在のPATHを取得
$currentPath = [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User)
# scripts ディレクトリがPATHに既に含まれていない場合に追加
if ($currentPath -notlike "*$scriptsDir*") {
# 新しいPATHを作成
$newPath = "$currentPath;$scriptsDir"
# ユーザーの環境変数PATHを更新
[System.Environment]::SetEnvironmentVariable("PATH", $newPath, [System.EnvironmentVariableTarget]::User)
# 現在のセッションに反映させる
$env:PATH = $newPath
Write-Output "Added '$scriptsDir' to PATH."
} else {
Write-Output "'$scriptsDir' is already in PATH."
}