Archive: WinVer.nsh - having a problem


WinVer.nsh - having a problem
WinVer.nsh provides a method to detect the OS Version and take certain actions thus:

${If} ${AtLeastWinVista}
--take certain action--
${Endif}

The above works nicely. But if I substitute a variable for "AtLeastWinVista" it doesn't work:

Var Min_OS_Ver
StrCpy $Min_OS_Ver "AtLeastWinVista"
${If} ${$Min_OS_Ver}
--take certain action--
${Endif}

Doesn't compile. I am using the OS Version testing at several places in my install source and want to define the test parameter at just one place.

Am I making a mistake or doesn't WinVer.nsh support this?


I don't know what you're trying to do.
I think something like this??

Var Min_OS_Ver
StrCpy $Min_OS_Ver ${AtLeastWinVista}
${If} $Min_OS_Ver
--take certain action--
${Endif}

I'm not even sure if that will work but it might.
${AtLeastWinVista} as ${If} are macros I think.


Why would you want to use a variable instead of ${AtLeastWinVista}? You can use ${AtLeastWinVista} more than once, you know. Just use it every time you need to know if the OS is Vista or higher.


MSG: The reason is I like to define all constants wherever possible in one place at the beginning in a group. I believe it is good practice rather than smearing them all around the place. This particular expression occurs in 3 different sections.

msroboto: Ill try what you suggest when I get back.


You do not use variables and StrCpy to define constants. Use !define, which will work here.

Stu


msroboto: What you suggested didn't work. The error message was: "_If" required 4 parameter(s), passed 2!

Afro UK: I have tried:

!define Min_OS "AtLeastWinXP"
..
..
${If} ${Min_OS} as well as ${If} ${"Min_OS"} and get exactly the same error.

Of course ${If} ${AtLeastWinXP} works so I know I am using that correctly.

I would like to get this working so that I can define the second parameter once at the beginning of the installer. I use it in several sections including the uninstaller. So it is desirable to define it just once if possible.


Both "${If}" & "${AtLeastWinVista}" are macros, they will be replcce with the pre-defined string when compiling. But the value of $Min_OS_Ver only would be known when running.


!define Min_OS ${AtLeastWinXP}
${If} ${Min_OS}

should work.

Stu


Stu:

!define Min_OS ${AtLeastWinXP}
${If} ${Min_OS}

Worked! Thank you! I will be using AtLeastVista to put user data in $APPDATA as needed for Vista and W7. Up to this point user data has gone in $INSTDIR, too late to change that for XP without causing user confusion.


You mean, too late for Win95+IE4 ? ;)


can anyone plz help me out, i found WinVer.nsh with windows 8 detection, or at least i think so :)
http://nsis.svn.sourceforge.net/view...p&pathrev=6249
but don't know how to use it in my code for example:

!include LogicLib.nsh
!include UAC.nsh
!include WinVer.nsh

Function .onInit
${WinVerGetMajor} $1
DetailPrint "Major version = $1"
${WinVerGetMinor} $2
DetailPrint "Minor version = $2"
${WinVerGetBuild} $3
DetailPrint "Build number = $3"

FunctionEnd

This one does not work.


Should work as usual:

${If} ${IsNT}
${If} ${AtLeastWin8}
MessageBox MB_OK "You have Windows 8 or a future version!"
${EndIf}

${If} ${IsWin8}
MessageBox MB_OK "Your system is Windows 8!"
${EndIf}

${If} ${IsAtMostWin8}
MessageBox MB_OK "You have Windows 8 or an older version!"
${EndIf}
${EndIf}


And don't let yourself get confused by Microsoft's marketing department!
The so-called "Windows 8" in fact is Windows NT 6.2, so that's probably what you get when you read the "raw" version numbers ;)

Originally posted by hedrox
can anyone plz help me out, i found WinVer.nsh with windows 8 detection, or at least i think so :)
http://nsis.svn.sourceforge.net/view...p&pathrev=6249
but don't know how to use it in my code for example:
The .nsh in SVN is not compatible with 2.46 but you can grab the version number from there and modify your local .nsh...