Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSIS Detect Windows Version

In NSIS is there a way to determine what version of windows the user is currently running?

The reason I want to do this is because my installer looks different on a Windows XP computer. My installer uses MUI2 but I dont seem to have the same GUI buttons(I think its called XP Style) as I do in Windows 7 and the main installer window is much larger than in Windows 7(where its about 500 by 400 pixels). Is it normal to a have these differences in an installer using MUI2? I thought MUI2 made the look consistant in windows versions XP and up?

To overcome the difference in installer window size, my solution is to detect if the user is using Windows XP and resize the window accordingly. Is this possible?

I need to have the window a specific size because I have a background image and the image is 500px wide so if the installer window is bigger I have a blank gap. I can change the background image to be wider but the easiest solution for myself is the one I explained above

like image 217
sazr Avatar asked Jan 19 '13 00:01

sazr


People also ask

What version of Windows is my NSIS running?

NSIS includes a header file aptly named WinVer.nsh since version 2.21. It allows for easy detection of the Windows version using LogicLib macros and has automatic future-support so you can always tell if the system at hand, even if undetected, is newer or older than what you need.

How to fix NSIS installer error on Windows 11?

Another easy way to fix the NSIS installer error is to rename the installer. Renaming any file on Windows 11 is easy. Here’s how to do it. Locate the installer you want to rename using File Explorer. Select the installer file and press F2. Enter a new name for your file.

Where is the NSIS NSH file located?

There are some more functions and some usage examples in the WinVer.nsh file, which is probably located somewhere like C:\Program Files\NSIS\Include, like: AtLeastServicePackwhich checks if the installer is running on Windows service pack version at least as specified.

Does NSIS support Windows 8 and 81?

The alpha release of NSIS (3.0a2) supports Windows 8 and 8.1. If you wish to detect Windows 8 and 8.1 rather than just $ {AtLeastWin7} or similar with NSIS stable you can use this script or update your local WinVer.nsh with the missing defines and macros from NSIS 3 (This will fix Windows 8 but 8.1 lies unless you have the correct manifest ).


1 Answers

In case Anders' answer is not explicit enough (took me a few hours to get it right), here is a more "beginner's friendly" version.

You will need to add !include WinVer.nsh to the top section of the cd.nsi file.

You then can use code like this:

${If} ${IsWinXP}
     MessageBox MB_OK|MB_ICONEXCLAMATION "We have Win XP"
${EndIf}

This is the only function I tested, but the WinVer.nsh file starts with a mini-manual with its functions, which include:

  • AtLeastWin<version> which checks if the installer is running on Windows version at least as specified.
  • IsWin<version> which checks if the installer is running on Windows version exactly as specified.
  • AtMostWin<version> which checks if the installer is running on Windows version at most as specified.

<version> can be replaced with the following values (and maybe more, depending on how recent your WinVer.nsh file is): 95, 98, ME, NT4, 2000, XP, 2003, Vista, 2008, 7, 2008R2

There are some more functions and some usage examples in the WinVer.nsh file, which is probably located somewhere like C:\Program Files\NSIS\Include, like:

  • AtLeastServicePack which checks if the installer is running on Windows service pack version at least as specified.
  • IsServicePack which checks if the installer is running on Windows service pack version exactly as specified.
  • AtMostServicePack which checks if the installer is running on Windows service version pack at most as specified.
  • IsWin2003R2 (no more details supplied)
  • IsStarterEdition (no more details supplied)
  • OSHasMediaCenter (no more details supplied)
  • OSHasTabletSupport (no more details supplied)
like image 171
Danny Schoemann Avatar answered Oct 11 '22 05:10

Danny Schoemann