0

I made this script to install Flutter:

Write-Host "Installing Flutter..." -ForegroundColor Cyan
$zipFile = "$env:TEMP\flutter.zip"

Write-Host "Downloading..."
(New-Object Net.WebClient).DownloadFile('https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_3.0.5-stable.zip', $zipFile)

Write-Host "Unzipping..."
Expand-Archive -Path "$zipFile" -DestinationPath "C:\src\flutter" -Verbose

[Environment]::SetEnvironmentVariable('Path', "$([Environment]::GetEnvironmentVariable('Path', 'Machine'));C:\src\flutter\flutter\bin", 'Machine')

flutter --version

it fails on the flutter --version because I have to reload the PowerShell for the new PATH to have an effect. Is there a command to reload the PATH while running the script? I needed this to work on the current shell as well, but not setting a temporary path on the current shell, that is, I need to test if this set really worked

Guerlando OCs
  • 1,886
  • 9
  • 61
  • 150
  • 1
    Duplicate of [Reload the path in PowerShell](https://stackoverflow.com/questions/17794507/reload-the-path-in-powershell) – Herohtar Aug 12 '22 at 20:15
  • 1
    In addition to the solutions in the linked duplicate, in your case you can take a shortcut, since you know the directory that was just added: `$env:PATH += ";C:\src\flutter\flutter\bin"` – mklement0 Aug 12 '22 at 20:24

0 Answers0