Archive: NSIS scripting OS nitpicking


NSIS scripting OS nitpicking
I have one program that has two versions: a version that works only on Windows 9x/NT4, and a version that works on Windows 2k/XP/Vista. Here is my problem: I need a way to make installers that either have both versions but distinguish between OSes to choose which files are allowed to be installed, or two separate installers that have OS checks to allow only certain OSes to run the installers... Can someone help me with this? I am using MUI-compatible skinning and base MUI.
I also need help designing my installer to work with Limited Users, while allowing installations System-wide if Administrators are logged in and running the installation.


Use GetVersion plugin or GetWindowsVersion function.

Edit: GetVersion plugin support added for Windows Vista and Longhorn Server.

-Stu


That solves one part of it, now I just need to know how to use it for my situation....


For example:


!include LogicLib.nsh

Section

GetVersion::WindowsName
Pop $R0
StrCpy $R0 $R0 2 8

${If} $R0 == 98
${OrIf} $R0 == 95
${OrIf} $R0 == NT

## Extract 9x/NT files

${ElseIf} $R0 == XP
${OrIf} $R0 == 20 # 2000
${OrIf} $R0 == Vi # Vista

## Extract XP/2000/Vista files

${EndIf}

SectionEnd


-Stu

So, with this I can use one installer to install different versions of a program on different versions of Windows? Well, unfortunately, I am extremely stupid on NSIS at the moment... Can you please make a complete example script for me?


There are already many example scripts bundled with NSIS. Rather than having a Section for each installation (for different Windows) you just use this code inside a Section (it already is in fact).

I've put comments in there where you need to put the relevant instructions (SetOutPath, File etc) for the individual installations.

-Stu