1
我在更新PATH變量時遇到問題。我需要做的是更新路徑(工作正常),然後立即在安裝程序中使用新版本。這不起作用。在同一安裝程序中使用更新的NSIS路徑
這裏是我使用更新的路徑是什麼:
!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是否無法更新?
而且,如果你想要一個看起來不那麼嚇人,`裏System :: Call的Kernel32 :: SetEnvironmentVariable方法(T 「PATH」,tR1的)`(其中$ 1是新的路徑) – 2010-11-28 12:28:10