Question Probleme de mise a jour de $env: Path

Plus d'informations
il y a 15 ans 2 mois #3770 par Tarik
Merci, pour vos aides, j'ai résolu mon problème en modifiant la variable premiérement au niveau du process. Et finalement j'ai écraser la variable au niveau machine avec celle du process. Ici un aperçu du code.

[code:1]# Appends useful paths to the PATH Variable
Function Add2Path($Name, $pathFolder, $Scope)
{
Write-Host \"INFO: Adding $pathFolder in environment variable $Name in $Scope scope.\"
$CurrentPathVar = $env: path.ToString().ToLower()
If ($CurrentPathVar.Contains($pathFolder.ToLower())){
Write-Host \"INFO: $pathFolder is already in the path\"
}else{
## Warning $env: Path is modified at level Process,
## Otherwise wrong value will be modified and change will not take affect on Machine for other scripts.
[Environment]:: SetEnvironmentVariable($Name, $env: Path+\";$pathFolder\", $Scope)
Write-Host -ForegroundColor green \"SUCCESS: $pathFolder was added to the path\"
}
}


foreach($EnvironmentVariableNode in $EnvironmentVariableNodes){
Switch($EnvironmentVariableNode.Operation){
\"Append\"{
Add2Path $EnvironmentVariableNode.Name $EnvironmentVariableNode.Value \"Process\"
}
default{}
}
}
## Warning $env: Path from Machine level is replace by the Process Level $env: Path modified previously
## This will prevent to have the right value in the $env: Path Machine level.
[Environment]:: SetEnvironmentVariable(\"Path\", $env: Path, \"Machine\"«»)[/code:1]

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.530 secondes
Propulsé par Kunena