Erlang:如何安装Erlang for Windows并指定位置

axkjgtzd  于 2023-10-14  发布在  Erlang
关注(0)|答案(2)|浏览(221)

我想安装Erlang for Windows。Erlang提供了一个Windows安装程序,但安装程序将Erlang安装到固定文件夹“Program Files”中。我需要安装Erlang到可选位置。
请告诉我如何安装Erlang for Windows,并告诉我想要安装的路径。

kadbb459

kadbb4591#

您可以运行以下命令来指定其他安装位置。请注意,您应该以管理用户身份运行安装程序:

otp_win64_20.3.exe /S /D=C:\the\path\you\want
knsnq2tg

knsnq2tg2#

谢谢@Luke Bakken的回答。我可以将其 Package 到我的脚本中,并复制到这里,以防有人发现它有用。我也借了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")
    }
}

相关问题