Reputation: 525
I would like to install Erlang for Windows. Erlang provides a Windows installer but the installer installs Erlang into fixed folder "Program Files". I need to install Erlang into optional location.
Please let me know how to install Erlang for Windows with a path which I want to install.
Upvotes: 2
Views: 3394
Reputation: 9637
You can run the following command to specify a different installation location. Note that you should run the installer as an administrative user:
otp_win64_20.3.exe /S /D=C:\the\path\you\want
Upvotes: 3
Reputation: 428
Thanks @Luke Bakken for your answer. I was able to wrap this into my script and am copying this here in case someone finds it useful. I also borrowed from https://gist.github.com/chgeuer/8342314
Function Install-Erlang {
Try{
"Starting Erlang installation..."
# Install Erlang
# Update/review below path along with version of erlang being installed
$args = "/S /D=C:\erl10.2"
Start-Process -Wait otp_win64_21.2.exe -ArgumentList $args
}
Catch{
Write-Error "Function Install-Prerequisites failed:" $_
Exit 1
}
"Erlang installed successfully"
#
# Determine Erlang home path
#
$ERLANG_HOME = ((Get-ChildItem HKLM:\SOFTWARE\Wow6432Node\Ericsson\Erlang)[0] | Get-ItemProperty).'(default)'
[System.Environment]::SetEnvironmentVariable("ERLANG_HOME", $ERLANG_HOME, "Machine")
#
# Add Erlang to the path if needed
#
$system_path_elems = [System.Environment]::GetEnvironmentVariable("PATH", "Machine").Split(";")
if (!$system_path_elems.Contains("%ERLANG_HOME%\bin") -and !$system_path_elems.Contains("$ERLANG_HOME\bin"))
{
Write-Host "Adding erlang to path"
$newpath = [System.String]::Join(";", $system_path_elems + "$ERLANG_HOME\bin")
[System.Environment]::SetEnvironmentVariable("PATH", $newpath, "Machine")
}
}
Upvotes: 4