【问题标题】:Using updated NSIS path within the same installer在同一安装程序中使用更新的 NSIS 路径
【发布时间】:2010-11-28 20:11:08
【问题描述】:

我在更新 PATH 变量时遇到问题。我需要做的是更新路径(工作正常),然后立即在安装程序中使用新版本。这不起作用。

这是我用来更新路径的内容:

!macro ADD_TO_PATH pathAdd
       DetailPrint "Adding ${pathAdd} to the system PATH."
       ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH"
       WriteRegStr ${WriteEnvStr_RegKey} "PATH" "$1;${pathAdd}"
       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000

       ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH"
       MessageBox MB_OK "Path: $1"

!macroend

这是我需要做的:

Section "${PRODUCT_NAME}" SEC_R

        DetailPrint 'Installing Python Dateutil...'
        !insertmacro EXEC_OUT 'dtutil' 'easy_install python-dateutil' 'DateUtil' 'true'

SectionEnd

EXEC_OUT 如下:

; Silent execution of easy_install.
; abrt    - is set to 'true', causes Abort on failure.
; name    - user-friendly name to print
; package - unique name for labels
; what    - full command to execute(ex: "easy_install packageXYZ")
!macro EXEC_OUT package what name abrt

       MessageBox MB_OK "what: ${what}"
       ExecWait "${what}" $0
       ${If} $0 == "0"
             DetailPrint "${name} module installed successfully."
       ${Else}
              DetailPrint "${name} failed to install: $0"
             ${If} ${abrt} == "true"
                  abort "An essential part of the installation, ${name}, failed to install. Aborting installation."
             ${EndIf}
       ${EndIf}

!macroend

为什么这不起作用?在应用退出之前不能更新PATH吗?

【问题讨论】:

    标签: path nsis


    【解决方案1】:

    您还需要为正在运行的进程设置环境变量。

    http://nsis.sourceforge.net/Setting_Environment_Variables_to_Active_Installer_Process

    【讨论】:

    • 如果你想让它看起来不那么可怕,System::Call Kernel32::SetEnvironmentVariable(t"PATH",tR1)(其中 $1 是新的 PATH)
    猜你喜欢
    • 2013-05-25
    • 2016-05-04
    • 2020-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多