The below code can be used to append path environment variable.
In the similar way, you can set/Append any environment variables in windows.
Param
(
[Parameter(Mandatory=$false)]
[System.String]
$pathtoAppend = "C:\Tools\java\bin"
)
$env_Path = [Environment]::GetEnvironmentVariable("Path","Machine")
$finalPath = "$env_Path;$pathtoAppend"
[Environment]::SetEnvironmentVariable("Path",$finalPath ,"Machine")
In the similar way, you can set/Append any environment variables in windows.
No comments:
Post a Comment