if ($PSScriptRoot) { Set-Location $PSScriptRoot } $currentDir = $PWD.Path $adb = Join-Path $currentDir "platform-tools-latest-windows\platform-tools" $oldPath = [Environment]::GetEnvironmentVariable("Path", "User") $list = $oldPath -split ";" | Where-Object { $_ -ne "" } $list = $list | Where-Object { $_ -ne $currentDir -and $_ -notlike "*platform-tools*" } $targets = @($currentDir, $adb) foreach ($p in $targets) { if ($p -and (Test-Path $p)) { $list += $p } } $newPath = $list -join ";" [Environment]::SetEnvironmentVariable("Path", $newPath, "User") $currentDir $adb