Search code examples
nsis

Two .exe versions for different operating systems


My NSIS based installer deploys a certain .exe file into the target folder for all windows platforms. We recently discovered we need to deploy a slightly different version of that .exe file if we are installing on windows 8.

We don't want to have two installers. we'd rather have one installer that "holds" the two .exe files, and deploys the right one for windows8 and the other .exe for the rest.

Any pointers on How do we achieve that? detecting windows8 at install time, copying over a different version of the .exe file when we do detect it?

Thanks.


Solution

  • You can test quite precisely the platform by including the LogicLib.nsh and WinVer.nsh scripts that are provided with NSIS.

    Here is a function that I am using where I make some sanity checks before installing an application:

    Function CheckUnsupportedPlatform
        ${if} ${AtLeastWin95}
        ${AndIf} ${AtMostWinME}
            ;NT4 and W95 use the same version number, we can use ${IsNT} if we need precise identification
            MessageBox MB_OK|MB_ICONEXCLAMATION "Sorry, but your version of Windows is unsupported platform.$\n\
    Supported platforms are currently 2000 / XP / 2003 / Vista / Seven$\n \
                Cannot continue the installation." /SD IDOK
            abort
        ${elseIf} ${isWin2008}
        ${orIf} ${AtLeastWin2008R2}
            MessageBox MB_OK|MB_ICONINFORMATION "Please note that support for Windows 2008 and Windows 8 is in beta stage.$\n\
    Supported platforms are currently 2000 / XP / 2003 / Vista / Seven" /SD IDOK
        ${endif}
    FunctionEnd
    

    There are many more possibilities, take a look in the header of WinVer.nsh for more examples.