mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
tools: fix install-powershell for running during window setup (#5727)
Set the system path instead of the user path so that all users can use the installation
If the required destination folder doesn't exist, create it
This commit is contained in:
1 parent
ad231a8a7f
commit
359a3f078e
1 file changed
+6
-5
@@ -153,6 +153,7 @@ try {
|
||||
Copy-Item $_.fullname -Destination $DestinationFilePath
|
||||
}
|
||||
} else {
|
||||
$null = New-Item -Path (Split-Path -Path $Destination -Parent) -ItemType Directory -ErrorAction SilentlyContinue
|
||||
Move-Item -Path $contentPath -Destination $Destination
|
||||
}
|
||||
|
||||
@@ -173,11 +174,11 @@ try {
|
||||
if (-not $IsWinEnv) { chmod 755 $Destination/pwsh }
|
||||
|
||||
if ($AddToPath) {
|
||||
if ($IsWinEnv -and (-not $env:Path.Contains($Destination))) {
|
||||
## Add to the User scope 'Path' environment variable
|
||||
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||
$userPath = $Destination + [System.IO.Path]::PathSeparator + $userPath
|
||||
[System.Environment]::SetEnvironmentVariable("Path", $userPath, "User")
|
||||
if ($IsWinEnv -and (-not [System.Environment]::GetEnvironmentVariable("Path", "Machine").Contains($Destination))) {
|
||||
## Add to the Machine scope 'Path' environment variable
|
||||
$machinePath = [System.Environment]::GetEnvironmentVariable("Path", "Machine")
|
||||
$machinePath = $Destination + [System.IO.Path]::PathSeparator + $machinePath
|
||||
[System.Environment]::SetEnvironmentVariable("Path", $machinePath, "Machine")
|
||||
Write-Verbose "'$Destination' is added to the Path" -Verbose
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user