Two .exe versions for different operating systems

My NSIS-based installer deploys a specific .exe file to a destination folder for all Windows platforms. We recently discovered that we need to deploy a slightly different version of this .exe file if we install on Windows 8.

We do not want to have two installers. we would prefer to have one installer that β€œstores” two .exe files and deploys the right one for Windows8, and the other .exe for the rest.

Any pointers to How do we achieve this? detection of windows8 during installation, copying to a different version of the .exe file, when will we detect it?

Thanks.

+4
source share
3 answers

You can test the platform fairly accurately by including the LogicLib.nsh and WinVer.nsh scripts provided by NSIS.

Here is the function I use, where I do some sanity checks before installing the 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 other possibilities, look again at the WinVer.nsh header.

+2
source

I had a similar problem with nsis, which was detecting different versions of Windows. I just wrote a three-line C ++ application to call the Windows API to find out the OS version, and then write the console output as a string. From nsis, you can read this output in a variable, and then switch to the value of this variable.

+1
source

I know this is pretty old, but if anyone has a problem with the File command, this is the expected syntax:

 !include "WinVer.nsh" ... ; The stuff to install Section "MyProgram (required)" ${If} ${AtMostWin2003} File /oname=MyFile.exe "MyFile2003.exe" ${Else} File "MyFile.exe" ${EndIf} SectionEnd 
0
source

Source: https://habr.com/ru/post/1441847/


All Articles