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

2
  • 1
    Duplicate of Reload the path in PowerShell Commented Aug 12, 2022 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" Commented Aug 12, 2022 at 20:24

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.