我已经建立了一个NSIS,它已经可以正常工作几个月了,突然,JRE的下载失败出现了问题,我已经测试了下载链接是否正常,请提出以下可能的解决方案,如果有人可以帮助部分代码,则列出如下:
!define JRE_URL "javadl.sun.com/webapps/download/AutoDL?BundleId=69476"
Function GetJRE
MessageBox MB_OK "${PRODUCT_NAME} uses Java ${JRE_VERSION}, it will now \
be downloaded and installed"
StrCpy $2 "$TEMP\Java Runtime Environment.exe"
nsisdl::download /TIMEOUT=30000 ${JRE_URL} $2
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
MessageBox MB_OK "Download failed: $R0"
Quit
ExecWait $2
Delete $2
FunctionEnd
Function DetectJRE
Push $0
Push $1
; for 64-bit registry
SetRegView 64
ReadRegStr $3 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
;MessageBox MB_OK "JRE CurrentVersion $3"
;StrCmp $3 ${JRE_VERSION} Done
StrCpy $0 $3 1 0
StrCpy $1 $3 1 2
StrCpy $4 "$0$1"
;MessageBox MB_OK "JR CurrentVersion $JR_VERSION"
;MessageBox MB_OK "JR CurrentVersion $4"
IntCmp 16 $4 Done JavaVerNotCorrect JavaVerNotCorrect # if not JRE 1.6,download from the web
JavaVerNotCorrect:
Call GetJRE
Done:
Pop $1
Pop $0
FunctionEnd
nsisDl使用自定义HTTP库。使用INetC代替,它使用与Internet Explorer相同的HTTP库。