Search code examples
javaruntimensis

Can't copy a directory in runtime NSIS and there is no way to get JRE bit version?


I am trying to copy the JRE's directory to my Install directory but the compiler says there is no such file but when I run my Install I put it on the label and it shows me the directorys path. I know that File only accepts precompiled variables but there is no workaround ? I am very new to NSI scripting just started 2 days ago and I try to get the JRE's bit version but still no luck how to do it...

Here is my code where I try to copy and get bit version but fails:

Var jredir

RequestExecutionLevel admin
Function nsDialogsPage

nsDialogs::Create 1018


    ${NSD_CreateLabel} 0 0 100% 12u "Cheking for JRE information..."
    Pop $Label

    ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" CurrentVersion
    ${NSD_CreateLabel} 0 15 100% 12u "JRE version: $0"
    Pop $Label
    ${NSD_CreateLabel} 0 30 100% 12u "JRE bit: xx"
    Pop $Label



    ReadRegStr $1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$0" "JavaHome"
    StrCpy $jredir $1
        ${NSD_CreateLabel} 0 45 100% 12u "JRE directory: $1"
    Pop $Label

        IfFileExists "$jredir" CopyJRE GetJRE

        CopyJRE:
        SetOutPath $INSTDIR
        File /r "$jredir"


        GetJRE:
        ${NSD_CreateLink} 0 183 100% 12u "Download JRE"
        Pop $Link
        ${NSD_OnClick} $Link onMyLinkClick

    nsDialogs::Show
FunctionEnd

Function onMyLinkClick
Pop $0
ExecShell "open" "http://www.java.com/en/download/index.jsp"
FunctionEnd

Solution

  • The File instruction cannot use $variables because those variables only exist at run-time on the end-users machine and the File instruction needs to access the files on the developers machine while building the installer.

    You can use CopyFiles to copy files at run-time...