Last active
February 1, 2024 13:27
-
-
Save tebeco/5c6cc0eee8c28fad3523008d58f83914 to your computer and use it in GitHub Desktop.
fix dotnet path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$OldSysPath=[System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine); ` | |
$Hasx86=($OldSysPath.Split(';') | ? { $_.StartsWith('C:\Program Files (x86)\dotnet\')}).Count -gt 0; ` | |
if ($Hasx86) { | |
Write-Host "**********************************************************************"; ` | |
Write-Host "If you're seing this message your SYS PATH is improperly set" -ForegroundColor Yellow; ` | |
$NewSystemPath=$OldSysPath.Replace('C:\Program Files (x86)\dotnet\', 'C:\Program Files\dotnet\'); ` | |
Write-Host "**********************************************************************"; ` | |
Write-Host "Your Old PATH was:" -ForegroundColor Green; ` | |
Write-Host "$($OldSysPath)"; ` | |
Write-Host "**********************************************************************"; ` | |
Write-Host "Your New PATH will be:" -ForegroundColor Green; ` | |
Write-Host "$($NewSystemPath)"; ` | |
Write-Host "Press enter to continue (Ctrl+C to ABORT)" -ForegroundColor Red -NoNewLine; Read-Host; ` | |
Write-Host "**********************************************************************"; ` | |
[System.Environment]::SetEnvironmentVariable('PATH', $NewSystemPath, [System.EnvironmentVariableTarget]::Machine) ` | |
} | |
else { | |
Write-Host "**********************************************************************"; ` | |
Write-Host "Everything seems fine as we could not find a match in PATH for 'C:\Program Files (x86)\dotnet\' ... which is fine" -ForegroundColor Green ` | |
Write-Host "**********************************************************************"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment